Simple add a wait which delays the script for a little in seconds. We also need the debounce itself. Debounces work by using an if statment to check if it's a certain value. If it is that value matches it changes the value so the if statement doesn't run again until the debounce is back to the original value. Bools are the most used since it only has 2 values. True or False, 1 or 0, On or Off.
Finished Product:
local debounce = false
function BackwardsWorld(plr)
local human = plr.Parent:FindFirstChild("Humanoid")
if human and not debounce then
debounce = true
human.WalkSpeed = human.WalkSpeed - 32
local m = Instance.new("Message")
m.Parent = game.Workspace
m.Text = plr.Parent.Name.." has entered the backwards world!"
wait(3)
m:Destroy()
debounce = false
if human ~= nil and human.WalkSpeed < 0 then
human.WalkSpeed = 16
local m2 = Instance.new("Message", workspace)
m2.Text = plr.Parent.Name.." has entered the regular world!"
wait(3)
m2:remove()
end
end
end
script.Parent.Touched:connect(BackwardsWorld)
EDIT
New script. I think I know what you want it to do.
local debounce = false
function BackwardsWorld(plr)
local human = plr.Parent:FindFirstChild("Humanoid")
if human and not debounce and humanoid.WalkSpeed > 0 then
debounce = true
human.WalkSpeed = human.WalkSpeed - 32
local m = Instance.new("Message")
m.Parent = game.Workspace
m.Text = plr.Parent.Name.." has entered the backwards world!"
m:Destroy()
elseif human and human.WalkSpeed < 0 then
human.WalkSpeed = 16
local m2 = Instance.new("Message", workspace)
m2.Text = plr.Parent.Name.." has entered the regular world!"
wait(3)
m2:remove()
end
wait(3)
debounce = false
end
end
script.Parent.Touched:connect(BackwardsWorld)
2 comments
The problem is I don't know how you want it to work. You are too broad.
I edited the script. I think I know what you want it to do.