I’m trying to make it so that when you click the button it changes your walkspeed which works, but the cooldown is able to be bypassed and glitched
local button = script.Parent:WaitForChild("lol")
local textlabal = script.Parent:WaitForChild("lol2")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local debounce = true
local randomnum = 100
button.Activated:Connect(function(a)
if a then
if debounce then
humanoid.WalkSpeed = Random.new():NextNumber(0,randomnum)
textlabal.Text = "Walkspeed: "..math.floor(humanoid.WalkSpeed)
textlabal.TextColor3 = Color3.fromRGB(255, 0, 0)
end
debounce = false
task.wait(5)
if not debounce then
debounce = true
textlabal.TextColor3 = Color3.fromRGB(255, 255, 255)
end
end
end)
I’m an absolute beginner at scripting so if i do smth stupid that’s on me
after activating the button, you should check if debounce is set to false.
button.Activated:Connect(function(a))
if not debounce then return end
also i just want to show the way i would have made the script since you are a beginner.
local button = script.Parent:WaitForChild("lol")
local textlabal = script.Parent:WaitForChild("lol2")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local canClickButton = true --> i would name it just to make things easier
button.MouseButton1Click:Connect(function()
if canClickButton == false then return end --> now you dont have to check if canClick is true
canClickButton = false
humanoid.WalkSpeed = math.random(0, 100) --> this is much simpler than the random.new() stuff but you only get integers
textlabal.Text = "Walkspeed: "..humanoid.WalkSpeed
textlabal.TextColor3 = Color3.fromRGB(255,0,0)
task.wait(5)
canClickButton = true
textlabal.TextColor3 = Color3.fromRGB(255, 255, 255)
end
i get so annoyed when scripts look unorganised so if you want to just go to the script tab and click format document