Hello, I have a strange issue with OnServerInvoke(). I am making a team system, where I want to make sure each team at least has 1 player, and a balancing system I will code in the future. However, the scripts are very delayed, not by a second, but a whole 1-2 minutes. I do not know what the cause is, as I’ve tried a local server, and in studio, however both produce the same result. There is no wait() or anything of the similar anywhere in the scripts, so that is why I am confused. Any help is appreciated, thank you
--Server
local central, enter = game.Teams["Central Powers"], game.Teams["Entente Powers"]
local teamTable = {
[1] = enter,
[2] = central
}
local function checkIfTeam(player, num)
local team = teamTable[num]
if #central:GetPlayers() >= 1 and #enter:GetPlayers() == 0 then
if team == central then
return false
else
player.Team = enter
return true
end
elseif #enter:GetPlayers() >= 1 and #central:GetPlayers() == 0 then
if team == enter then
return false
else
player.Team = enter
return true
end
end
player.Team = team
return(false)
end
canJoin.OnServerInvoke = checkIfTeam
--Client
for _, v in ipairs(script.Parent:GetChildren()) do
if v:IsA("ImageButton") then
v.MouseButton1Down:Connect(function()
print("hi :)")
--if timerEnabled == true then
print("hru :D")
script.click:Play()
local join = canJoin:InvokeServer(tonumber(v.Name))
print(join)
if join == false then
local tween = game:GetService("TweenService"):Create(script.Parent.Warning, TweenInfo.new(), {TextTransparency = 0})
tween:Play()
--end
end
end)
end
end