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

What is wrong with this script?

Asked by
iFurzy 35
7 years ago
Edited 7 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

If you switch teams from Bright green, then go back to that team, it stops working.

function onPlayerEntered(newPlayer)

    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"

    local points = Instance.new("IntValue")
    points.Name = "Currency"
    points.Value = 0

    stats.Parent = newPlayer 
    points.Parent = stats

    while true do
        if newPlayer.TeamColor == BrickColor.new('Bright green') then
            wait(5) 
            points.Value  = points.Value + 50
        end
    end

end

game.Players.PlayerAdded:connect(onPlayerEntered) 
0
errors? DeveloperSolo 370 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

You have to make sure the team color of the team you inserted is set to 'Bright green' or it will not work.

In the properties of TEAM [if you don't see it, go to Model > Services > Team]. add a new team, or go to toolbox, roblox sets, and insert 'Bright green team'. After that your code should work.

If you insert a new team, under properties of 'Team Color' find 'Bright green' and change to that. Then it should work

If it works, make sure to hit that 'answer' button to help us both out!

If it doesn't work, please comment down below if you find any errors.

Thanks.

Edit 1: Error: When a player gets off the green team, the script keeps looping and looping. Causing it to break.

Solution: Move the 'wait()' statement out of the if, under the while true loop.

Ad

Answer this question