Hello so I was making a script (or trying to) that would change the color of a part inside a model inside of a character when you step on something. The issue is I dont know how to make the script do it to the player’s character, but if your name is “Player1” in workspace,(see in script) it will work. Idk if it makes sense, but I need the script to change “Player1” to the player that steps on the part. I might need to change the whole script. thats ok.
script-
script.Parent.Touched:Connect(function()
workspace.Player1.Chest2.Mesh.BrickColor = BrickColor.Red()
end)
(Player1 was the username of a player, and it worked on them but only them if that makes sense)
script.Parent.Touched:Connect(function(touch)
touch.Parent.“Chest Name”.BrickColor = BrickColor.new(“color name”)
end)
I Don’t remember if it’s that because i use Color3 instead of BrickColors
script.Parent.Touched:Connect(function(hit) --What touched it
local BodyPart = hit.Parent:FindFirstChild("RightUpperArm") --Body part you want to change
if BodyPart ~= nil then --Checks if the BodyPart exists or referenced correctly
BodyPart.BrickColor = BrickColor.new("Bright Red") --changes the color
end
end)
The only issue with this is that im changing the color to a custom bodypart/brick, not a default bodypart if that makes sense,
(Mesh is what im trying to change the color of)
(Sorry im not very good at scripting)
Is it a Mesh or MeshPart?
I can’t see it since the 2 haves the same icon.
Mesh part, dose that matter? because it worked when i put my username in the script
Mesh, Meshparts, and Baseparts all have brickcolors. Did you try the script i gave you?
Yes but it isnt a a real offical bodypart if that makes sense, like its not a “LeftLowerLeg” Its a mesh part inside of a model, Idk if im just not changing the corret things in your script
Idk why it keeps replying with the script
Yea then just call it the name instead of RightUpperArm
How would I sense the part im trying to change is inside of a model inside of the character, unlike a “leftLowerLeg” which is just only inside the character
i sorry im so slow with scripting
Replace “RightUpperArm” with the name of the Meshpart you want to change
Idk if this picture explains it but
see how “Mesh” is inside of “Chest2”
i dont think the script is picking it up
i just want to know how to do that
instead of “head” or “LeftFoot”
im sorry
Ok seems like you dont know how to reference but ill change the BodyPart variable to
local BodyPart = hit.Parent:FindFirstChild("Chest2").Mesh
1 Like
Ok so this worked, i just didnt know how to get the script to the mesh or whatever, Thank you so much!
1 Like
I have a question (so sorry) if i wanted to make the script change the color of all the parts named “one” would i just do this?
script.Parent.Touched:Connect(function(hit) --What touched it
local BodyPart = hit.Parent:FindFirstChild("RightLeg2")GetChildren:("one")
if BodyPart ~= nil then --Checks if the BodyPart exists or referenced correctly
BodyPart.BrickColor = BrickColor.new("Sand blue") --changes the color
end
end)
Or something like this?
script.Parent.Touched:Connect(function(hit) --What touched it
local BodyPart = hit.Parent.RightLeg2:GetChildren("one")
if BodyPart ~= nil then --Checks if the BodyPart exists or referenced correctly
BodyPart.BrickColor = BrickColor.new("Sand blue") --changes the color
end
end)
i rlly dont want to make 100 differnt scripts inside one part so if you could understand this it would help
im so sorry
script.Parent.Touched:Connect(function(hit)
if hit.Parent:WaitForChild("HumanoidRootPart") then
local char = hit.Parent
for i, part in pairs(char:GetDescendants()) do
if part.Name == "one" then
part.BrickColor = BrickColor.new("Sand blue")
end
end
end
end
You would do it like this, also you should make sure the part which caused the “Touched” event to fire belongs to a player’s character model otherwise random parts could end up being recolored.
1 Like