when i press the play button. it automatically turns the parts green without needing to touch the base part.
script.Parent.BasePart.Touched:connect(function() for i,v in pairs(script.Parent:GetChildren()) do v.BrickColor = BrickColor.new("Bright green") end end)
local function onTouch(hit)
pairs(script.Parent:GetChildren()) do v.BrickColor = BrickColor.new("Bright green") end
end
script.Parent.BasePart.Touched:connect(onTouch)
game.Workspace.mapStorage.map.King.Torso.Touched:connect(onTouch)
--I think this should work
the reason it is doing that is because if any part touches it then it will change so I recommend doing this
function Touch(hit) if hit.Parent == hit.Parent:FindFirstChild("Humanoid") then if (human~= nil) then -- checks if it's a player for i,v in pairs(script.Parent:GetChildren()) do v.BrickColor = BrickColor.new("Bright green") end end end end script.Parent.Touched:connect(Touch)
Local B = script.Parent.BasePart
Local function boom() script.Parent.BrickColor = ("whatevercoloryouwant")
end
B.Touched:connect(boom)
Check this out!
script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then --check if it's an humanoid for i,v in pairs(script.Parent:GetChildren()) do v.BrickColor = BrickColor.new("Bright green") end end end)
If it works, please mark this answer as the correct one!
And as always, good scripting!