I have a script that when pushing a button it will start the game. But sometimes it doesn’t respond. It alwats registers that you pushed the button but it doesn’t always register on the server. Can anybody help me with this?
Client Script:
local replicatedstorage = game:GetService("ReplicatedStorage")
local events = replicatedstorage:WaitForChild("Events")
local startevent = events:WaitForChild("StartLevel")
script.Parent:WaitForChild("Start").Activated:Connect(function()
startevent:FireServer(script.Parent.LevelBox.Text, false)
end)
Server Script:
local replicatedstorage = game:GetService("ReplicatedStorage")
local serverscriptservice = game:GetService("ServerScriptService")
local events = replicatedstorage:WaitForChild("Events")
local info = workspace.Info
local round = require(serverscriptservice.Main.Round)
events:WaitForChild("StartLevel").OnServerEvent:Connect(function(player, level, intownlevel)
if level then
info.Level.Value = level
end
round.StartGame()
end)
Switch your server code to this and tell me what it prints:
--//Services
local replicatedstorage = game:GetService("ReplicatedStorage")
local serverscriptservice = game:GetService("ServerScriptService")
--//Modules
local round = require(serverscriptservice.Main.Round)
--//Variables
local events = replicatedstorage:WaitForChild("Events")
local info = workspace.Info
--//Functions
events.StartLevel.OnServerEvent:Connect(function(player, level, intownlevel)
print("Event fired")
print("Level: ".. level)
if level then
info.Level.Value = level
end
round.StartGame()
end)