Why won’t this work? Am I missing something or is something else wrong?
local winner = script.Parent
local timer = game.StarterGui.timer.timer.timer
local player = game.Players.PlayerAdded:Wait()
local character = game.Players.PlayerAdded:Wait().Character
local teams = game.Teams
while true do
if timer.Text == "Intermission.." then
player.TeamColor = BrickColor.new("White")
character.Parent = workspace.PlayerWaitingFolder
elseif timer.Text == "Round Starting" then
player.TeamColor = BrickColor.new("Lime green")
character.Parent = workspace.PlayerIngameFolder
print("work")
end
wait(0.1)
end
local winner = script.Parent
local teams = game.Teams
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local timer = player:WaitForChild("PlayerGui"):WaitForChild("timer"):WaitForChild("timer"):WaitForChild("timer")
while true do
if timer.Text == "Intermission.." then
player.TeamColor = BrickColor.new("White")
character.Parent = workspace.PlayerWaitingFolder
elseif timer.Text == "Round Starting" then
player.TeamColor = BrickColor.new("Lime green")
character.Parent = workspace.PlayerIngameFolder
print("work")
end
task.wait(0.1)
end
end)
end)
Also try to use remote events and local script + server script next time.
Phew, several problems here… First you are not accessing the services properly…
game.Players --This is incorrect
game:GetService("Players") --This is correct.
Next you are pulling the “timer” gui element from “StarterGui” this does not really exist during runtime.
You want:
playerGui = player.PlayerGui
And if your going to change the PlayerGui you want to do this from the client.
Players.PlayerAdded event isn’t going to do you much good client side. If it even actually ever fires.
No actually I’m not wrong. The correct way to retrieve the service instance is to use game:GetService(). While using “game.Service” name may sometimes work because you got lucky and the service name is actually the same name as the class. Your not getting the instance of that service your getting the class definition so no methods for that class will work as expected becuase the unique values for that instance are not available through the class definition.
A prime example of this was a post just earlier today where the OP was attempting to pull an NPC from replicated storage… He was using game.ReplicatedStorage and when running the code. He was getting errors saying that the NPC could not be located. The reason is as I just described.