So I am making a round-based game and the code works fine up until line 57. I call the all the clients and it should return true or false based on a certain bool value I placed inside the player on startup. here is the code inside the remotefunction.
local check = game:GetService("ReplicatedStorage").CheckInGame
local player = game:GetService("Players").LocalPlayer
function CheckInGame()
return player.InGame.Value
end
check.OnClientInvoke = CheckInGame
the odd thing is that I get no error and the code runs on like the bool value it returned was false. when I checked during the runtime the InGame bool value is true but it still returns the value of false and I double checked the naming and everything. This is the code for the main script in server script service.
local status = game:GetService("ReplicatedStorage").Status
local games = game:GetService("ServerStorage").Games:GetChildren()
local lobbyMusic = workspace.Music.LobbyMusic
local gameMusic60 = workspace.Music.GameMusic60
local check = game:GetService("ReplicatedStorage").CheckInGame
local makeTrue = game:GetService("ReplicatedStorage").MakeTrue
local makeFalse = game:GetService("ReplicatedStorage").MakeFalse
while true do
wait(1)
i = 10
while i ~= -1 do
wait(1)
status.Value = "Intermission: "..i
i = i - 1
end
status.Value = "Selecting Game"
wait(5)
local rand = math.random(1,#games)
local chosenGame = games[rand]
local clone = chosenGame:Clone()
clone.Parent = workspace
status.Value = "Game Chosen: "..games[rand].Name
wait(3)
status.Value = "Teleporting"
wait(2)
local points = clone.SpawnPoints:GetChildren()
for i,v in pairs(game:GetService("Players"):GetChildren()) do
local char = v.Character
local rand = math.random(1,#points)
if v then
if v.Character:FindFirstChild("Humanoid") then
makeTrue:FireAllClients()
char.HumanoidRootPart.CFrame = points[rand].CFrame
moduleMain = require(chosenGame.MainScript)
v.Character.Humanoid.WalkSpeed = 0
v.Character.Humanoid.JumpPower = 0
end
end
end
for i = 5,0,-1 do
wait(1)
status.Value = "Game In Starting: "..i
end
status.Value = "Loading Players"
wait()
workspace.Music.GameMusic60:Play()
for i = 10,0,-1 do
wait(.2)
workspace.Music.GameMusic60.Volume = workspace.Music.GameMusic60.Volume + .1
workspace.Music.LobbyMusic.Volume = workspace.Music.LobbyMusic.Volume - .1
end
wait()
for i,v in pairs(game:GetService("Players"):GetChildren()) do
if v then
if v.Character:FindFirstChild("Humanoid") then
if check:InvokeClient(v) == true then
v.Character.Humanoid.WalkSpeed = chosenGame.WalkSpeed
v.Character.Humanoid.JumpPower = chosenGame.JumpPower
end
end
end
end
local winners = moduleMain.Main(status)
repeat wait() until moduleMain.Main
status.Value = "Game Over"
for i,v in pairs(game:GetService("Players"):GetChildren()) do
if v then
if v.Character:FindFirstChild("Humanoid") then
---insert check
v.Character.Humanoid.WalkSpeed = 0
v.Character.Humanoid.JumpPower = 0
end
end
end
wait(3)
for i,v in pairs(game:GetService("Players"):GetChildren()) do
if v then
if v.Character:FindFirstChild("Humanoid") then
v.Character.Humanoid.WalkSpeed = 16
v.Character.Humanoid.JumpPower = 50
end
end
end
local winnerSorted = table.concat(winners,", ")
status.Value = "The Winners Are "..winnerSorted
wait(5)
end
