local part = game.Workspace:WaitForChild("BlueBrick")
part.Touched:Connect(function(plr)
local humanoid = plr.Parent:FindFirstChild("Humanoid")
if humanoid then
part.Color = Color3.fromRGB(255, 240, 28)
end
end)
part.TouchEnded:Connect(function(plr)
local humanoid = plr.Parent:FindFirstChild("Humanoid")
if humanoid then
part.Color = Color3.fromRGB(0, 0, 255)
end
end)
#Why so laggy when I accessed humanoid?
1 messages · Page 1 of 1 (latest)
Instead of staying one color when I walk on it, it will just go yellow to blue over and over again
Did you add the debounce?
Show the script
as in debounce you mean task.wait?
local part = game.Workspace:WaitForChild("BlueBrick")
part.Touched:Connect(function(plr)
local humanoid = plr.Parent:FindFirstChild("Humanoid")
if humanoid then
part.Color = Color3.fromRGB(255, 240, 28)
end
end)
part.TouchEnded:Connect(function(plr)
local humanoid = plr.Parent:FindFirstChild("Humanoid")
if humanoid then
part.Color = Color3.fromRGB(0, 0, 255)
task.wait(1)
end
end)
No thats not how you do a debounce
local part = game.Workspace:WaitForChild("BlueBrick")
local debounce = false
part.Touched:Connect(function(plr)
if debounce then
local humanoid = plr.Parent:FindFirstChild("Humanoid")
if humanoid then
part.Color = Color3.fromRGB(255, 240, 28)
end
debounce = true
task.wait(1)
debounce = false
end
end)
part.TouchEnded:Connect(function(plr)
if debounce then
local humanoid = plr.Parent:FindFirstChild("Humanoid")
if humanoid then
part.Color = Color3.fromRGB(0, 0, 255)
end
debounce = true
task.wait(1)
debounce = false
end
end)
try that
Won't work
Ok I tried it but now the color won't change
Set the debounce to true not false thats my mistake sorry