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

How would I make a script execute when someone is on a certain team?

Asked by
nap516 87
7 years ago

I was going to make the script give you 1 cash and destroy. Here is what I have so far:

script.Parent.ClickDetector.MouseClick:connect(function(c) if game.Players.LocalPlayer.TeamColor == ("Really red") then game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.Cash.Value + 1 wait(0.01) script.Parent:Destroy() end end)

No output.

0
answer pls nap516 87 — 7y

1 answer

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

First off, please use the lua button to show code, second off, I would try something along the lines of:

Problems:

  1. Define BrickColor as a BrickColor, not as a string.

  2. LocalPlayer is referenced in what I assume is a server script.

script.Parent.ClickDetector.MouseClick:connect(function(c)
    if c.TeamColor == BrickColor.new("Really red") then
        c.leaderstats.Cash.Value = c.leaderstats.Cash.Value + 1
        wait(0.01)
        script.Parent:Destroy()
    end
end)

Problems: 1. Define BrickColor as a BrickColor, not as a string. 2. LocalPlayer is referenced in what I assume is a server script. Wiki Reference

0
Doesn't work still, but thanks for the info. nap516 87 — 7y
0
Check the most recent edits, it should work now. SebbyTheGODKid 198 — 7y
0
still not nap516 87 — 7y
0
try the wiki, i don't have a lot of time to keep changing my answer, sorry. SebbyTheGODKid 198 — 7y
0
i got it. nap516 87 — 7y
Ad

Answer this question