How do I make it so that you'll earn cash once you're in the team?

My Type: Beginner At Scripting

Objective: Trying to make a script where if you go to the winner’s team you’ll get points once, but if you go to the neutral team you won’t get any points unless you go back to the winner’s team.

I’m trying to make a script where if you go to the finish line then you’ll get points, but the problem is, I tried making it so that if you touch it you’ll get points but this will make the player touch it all over again which will cause them to have unlimited points.

So, I tried another option where you’ll get points once if you’re in the winner’s team and you can’t get them again unless you go back to the neutral team and go back to the finish line.

So, I tried making the script and it worked well, but the problem is that it gives you cash each one second, and I only wanted it to give you cash once. I tried removing “while true do”, but it seems like it didn’t work.

game.Players.PlayerAdded:Connect(function(player)
	while true do
		wait(1)
		local Award

		if player.TeamColor == BrickColor.new("Bright red") then --Bright red is the winner's team
			Award = 2500 
		else --If you go back to the neutral team then you won't get any points unless you go back to the winner's team
			Award = 0
		end

		player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + Award
	end
end)

(Sorry if I explained this really badly, I’m pretty bad at explaining)

player:GetPropertyChangedSignal("Team"):Connect(function()
    if player.Team == winnerTeam then
        player.leaderstats.Cash.Value+=250
    end
end)
1 Like

You could use a method like this, and change their team to “Winners” (or whatever your team is named) when they reach the finish line.

game.Teams.Winners.PlayerAdded:Connect(function(plr)

	plr.leaderstats.Cash.Value += Award	

end)
2 Likes

Thanks, this worked so well, I tried using “if statements” instead of that since I only know the basics, I’m going to try to look through more scripting methods, thanks!

1 Like