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

Color issues with NPC?[Solved]

I'm making a script that allows a player to place a minion type thing, and I want the arm colors of the NPC to change to the player's team color. Any ideas? This is the script:

wait()
local s = script.Parent.Selection
local p = script.Parent.Model
local canplace = false
local selected = false
local pos = Vector3.new(0,0,0)


script.Parent.Selected:connect(function(mouse)
selected = true
player = script.Parent.Parent.Parent
s.Parent = player.Character
mouse.Button1Down:connect(function()
if canplace then
--this is where it needs to find the team color and apply it to the NPC
s:Remove()
p.Parent = game.Workspace:FindFirstChild(player.Name)
p:MakeJoints()
script.Parent:Remove()
end
end)
while wait() do
if not selected then return false end
pos = Vector3.new(math.floor(mouse.Hit.p.X),math.floor(mouse.Hit.p.Y),math.floor(mouse.Hit.p.Z))
s.Position = pos+Vector3.new(0.5,0,0.5)
part,pos = workspace:FindPartOnRay(Ray.new(s.Position,Vector3.new(0,-0.2,0)),player.Character)
if part and part.BrickColor ~= BrickColor.Black() then
canplace = true
s.BrickColor = BrickColor.Green()
else
canplace = false
s.BrickColor = BrickColor.Red()
end
end
end)

script.Parent.Deselected:connect(function(m)
selected = false
s.Parent = script.Parent
end)

3 comments

0

What I would do is, find the color via the TeamColor property of the player, then set the arms BrickColor to whatever the TeamColor is.

0

I already tried that, idk why but the whole script stops working when i ask it to find script.Parent.Parent.Parent.TeamColor

0

Try and change their colors through the Body Color objects. That should work.

1 answer

✓ Accepted answer

s.BrickColor = BrickColor.Red()

It should be

s.BrickColor = BrickColor.new("ReallyRed")

3 comments

0

Same thing with green.

0

BrickColor.Red() is a object...there are a few colors you dont have to spell out. Also, "ReallyRed" wont work. it would be "Really Red" with a space

0

I made it clear where my issues were, there is nothing wrong with this script, i just couldnt add something to it. I made a seperate script for this.

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