Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

1 comment

0

answer pls

1 answer

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

5 comments

0

Doesn't work still, but thanks for the info.

0

Check the most recent edits, it should work now.

0

still not

0

try the wiki, i don't have a lot of time to keep changing my answer, sorry.

0

i got it.

This discussion is preserved as it was. New answers, comments, and votes are closed.