#Error in important script
6 messages · Page 1 of 1 (latest)
sending the script rq
local GameCore = {}
-- Shared variables
local players = {}
local gameMode = "lobby"
local gameSettings = {
maxPlayers = 10,
matchDuration = 30,
intermissionDuration = 10
}
-- Function to handle player connections and disconnections
function GameCore:PlayerConnected(player)
table.insert(players, player)
print("Player connected: " .. player.Name)
local playerGui = player.PlayerGui
local playerGuiElement = playerGui:WaitForChild("PlayerGuiElement")
playerGuiElement.TextLabel.Text = "Welcome, " .. player.Name .. "!"
end
function GameCore:PlayerDisconnected(player)
for i, p in ipairs(players) do
if p == player then
table.remove(players, i)
print("Player disconnected: " .. player.Name)
local playerGui = player.PlayerGui
local playerGuiElement = playerGui:WaitForChild("PlayerGuiElement")
playerGuiElement.TextLabel.Text = ""
end
end
end
-- Function to handle game mode changes
function GameCore:ChangeGameMode(newMode)
gameMode = newMode
print("Game mode changed to: " .. newMode)
local gameModeUi = game.ReplicatedStorage:WaitForChild("GameModeUi")
gameModeUi.TextLabel.Text = "Game mode: " .. gameMode
end
-- Function to handle game settings changes
function GameCore:ChangeGameSettings(newSettings)
gameSettings = newSettings
print("Game settings changed to:")
for setting, value in pairs(newSettings) do
print(setting .. ": " .. value)
end
end
-- Return the GameCore module
return GameCore
-- ModuleScript: GameModeManager
local GameModeManager = {}
function GameModeManager:ChangeGameMode(newMode)
local gameCore = require(game:GetService("ReplicatedStorage"):WaitForChild("GameCore"))
gameCore:ChangeGameMode(newMode)
end
local playerDisconnectedEvent = Instance.new("BindableEvent")
playerDisconnectedEvent.Name = "PlayerDisconnected"
playerDisconnectedEvent.Parent = ReplicatedStorage```
part 2: ```-- Create a function to handle player connections and disconnections
local function onPlayerConnected(player)
GameCore:PlayerConnected(player)
end
-- Create a function to handle player disconnections
local function onPlayerDisconnected(player)
GameCore:PlayerDisconnected(player)
end
-- Connect the player connected and disconnected events to the GameCore module
game.Players.PlayerAdded:Connect(onPlayerConnected)
game.Players.PlayerRemoving:Connect(onPlayerDisconnected)
-- Create a function to handle game mode changes
local function onChangeGameMode()
local gameModeUi = game.ReplicatedStorage:WaitForChild("GameModeUi")
local newMode = gameModeUi.TextLabel.Text
local gameCore = require(game:GetService("ReplicatedStorage"):WaitForChild("GameCore"))
gameCore:ChangeGameMode(newMode)
end
-- Connect the game mode change event to the onChangeGameMode function
game.ReplicatedStorage:WaitForChild("GameModeUi").TextChanged:Connect(onChangeGameMode)
-- Create a function to handle game settings changes
local function onChangeGameSettings()
local newSettings = {
maxPlayers = game.ReplicatedStorage:WaitForChild("GameSettings").MaxPlayers.Value,
matchDuration = game.ReplicatedStorage:WaitForChild("GameSettings").MatchDuration.Value,
intermissionDuration = game.ReplicatedStorage:WaitForChild("GameSettings").IntermissionDuration.Value
}
local gameCore = require(game:GetService("ReplicatedStorage"):WaitForChild("GameCore"))
gameCore:ChangeGameSettings(newSettings)
end
-- Connect the game settings change event to the onChangeGameSettings function
game.ReplicatedStorage:WaitForChild("GameSettings").MaxPlayers.Changed:Connect(onChangeGameSettings)
game.ReplicatedStorage:WaitForChild("GameSettings").MatchDuration.Changed:Connect(onChangeGameSettings)
game.ReplicatedStorage:WaitForChild("GameSettings").IntermissionDuration.Changed:Connect(onChangeGameSettings)```
it doesnt say any errors in the last part
but it doesnt work