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

Passed value is not a function?

Asked by
xg1y 41
6 years ago
1local function onTeamChange()
2a.TextLabel.TextColor3 = Player.Team.TeamColor.Color
3b.TextLabel.TextColor3 = Player.Team.TeamColor.Color
4end
5 
6Player:GetPropertyChangedSignal("Team"):Connect(onTeamChange())

Attempting to detect a team change and change a text label based on the teamchange but its throwing the error

Passed value is not a function

Any help is appreciated, cheers

1 answer

Log in to vote
1
Answered by 6 years ago

This is because you are trying to fire the function and connect it at the same time.

1local function onTeamChange()
2a.TextLabel.TextColor3 = Player.Team.TeamColor.Color
3b.TextLabel.TextColor3 = Player.Team.TeamColor.Color
4end
5 
6Player:GetPropertyChangedSignal("Team"):Connect(onTeamChange)

Easy fix is to just remove the () from here

1Player:GetPropertyChangedSignal("Team"):Connect(onTeamChange())

As they not needed.

Hope this solves your question :D

Ad

Answer this question