Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

why the function does not activate?

Asked by
lytew 99
4 years ago
Edited 4 years ago

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

0
Try using local function instead of function then. User#32819 0 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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 ()
0
the error stopped, but the function continues without activating lytew 99 — 4y
Ad

Answer this question