here's my code:
script.Parent.Touched:connect(function()
script.parent.BrickColor = BrickColor.new("Bright red")
end)
it automatically becomes red without me touching the part please help me
here's my code:
script.Parent.Touched:connect(function()
script.parent.BrickColor = BrickColor.new("Bright red")
end)
it automatically becomes red without me touching the part please help me
You need to check if a character stands on the part otherwise it would be red if anything touches it (such as an other part) so the updated code would be
script.Parent.Touched:Connect(function(part)
if (part.Parent:FindFirstChild("Humanoid") ~= nil) then
script.parent.BrickColor = BrickColor.new("Bright red")
end
end)
please accept my answer if it works
As it is, your touched event is checking for everyone, you want to check if its a player touching. Theres a quick way to do that as seen here:
script.Parent.Touched:connect(function(Hit)
local Plr = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Plr then
script.parent.BrickColor = BrickColor.new("Bright red")
end
end)
This checks to see if the player is what touched it.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
connect is deprecated. Please use Connect instead.