#Why so laggy when I accessed humanoid?

1 messages · Page 1 of 1 (latest)

maiden flicker
#
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)
#

Instead of staying one color when I walk on it, it will just go yellow to blue over and over again

polar quartz
#

Add a debounce

#

To avoid the event to be activated multiple times too fast

maiden flicker
#

Oh alright

#

its still kind of buggy

lost pawn
polar quartz
#

Show the script

maiden flicker
#
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)
lost pawn
#

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

maiden flicker
lost pawn
#

Set the debounce to true not false thats my mistake sorry

maiden flicker
#

Oh nice

#

thanks so much