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

How can I get this Bullet script to work?

Asked by 10 years ago

I have this script:

Bullet.BrickColor=BrickColor.new("New Yeller")

That makes the bullet that come out Yellow, I am trying to make it change the bullet color to your team color and cant find out how to do that. If you can, could you help me with that task?

2 answers

Log in to vote
1
Answered by
Redbullusa 1580 Moderation Voter
10 years ago

That depends whether your script is local or server-sided, although a local script is recommended to use.

If it's local-sided, you would simply use LocalPlayer.

Bullet.BrickColor = game.Players.LocalPlayer.TeamColor

If it's server-sided, you use the :GetPlayerFromCharacter() method.

Bullet.BrickColor = game.Players:GetPlayerFromCharacter(script.Parent.Parent).TeamColor

script.Parent.Parent assumes that script.Parent is the tool, and the parent of that is the character.

Ad
Log in to vote
2
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

Well, when working with anything that will be inside a Player, you should use a LocalScript. Now you can simply get the Player with game.Players.LocalPlayer

workspace.Part.BrickColor = game.Players.LocalPlayer.TeamColor
0
Thanks man I appreciate it! TixyScripter 115 — 10y

Answer this question