Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

why the function does not activate?

so, I created a script that changes a GUI to show what level a player is at.

game.Players.PlayerAdded:Wait()
function onChanged()
script.Parent.Text = script.Parent.Parent.Parent.Parent.RespawnLocation.Name
end
end

script.Parent.Parent.Parent.Parent.RespawnLocation.Changed:Connect(onChanged())

I said that the text that appeared in the Gui would be the name of the Player's RespawnLocation

my problem is that the function does not activate, even when the RespawnLocation is changed of the player

1 comment

0

Try using local function instead of function then.

1 answer

From what I know you can't use () of the function call in the event parameters. So remove the brackets so it's like this:

game.Players.PlayerAdded:Wait()
function onChanged()
script.Parent.Text = script.Parent.Parent.Parent.Parent.RespawnLocation.Name
end
end

script.Parent.Parent.Parent.Parent.RespawnLocation.Changed:Connect(onChanged) -- removed ()

1 comment

0

the error stopped, but the function continues without activating

This discussion is preserved as it was. New answers, comments, and votes are closed.