Please help me, whats wrong with this script?
local player = game.Players.LocalPlayer local mouse = player:GetMouse() mouse.KeyDown:connect(function(key) if key == "z" then game.ReplicatedStorage.OpeOpe.Barrier1:Clone().Parent = game.Workspace[player.Name.. "Skills"] game.Workspace[player.Name.. "Skills"].Barrier1.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position.X,player.Character.HumanoidRootPart.Position.Y,player.Character.HumanoidRootPart.Position.Z) wait(5) end end)
The wait(5) doesn't actually pause your tool from being used. Assuming there are no other issues in the script, this should work.
local usable = true local player = game.Players.LocalPlayer local mouse = player:GetMouse() mouse.KeyDown:connect(function(key) if key == "z" then usable = false game.ReplicatedStorage.OpeOpe.Barrier1:Clone().Parent = game.Workspace[player.Name.. "Skills"] game.Workspace[player.Name.. "Skills"].Barrier1.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position.X,player.Character.HumanoidRootPart.Position.Y,player.Character.HumanoidRootPart.Position.Z) wait(5) usable = true end end)
Do this:
local debounce = true mouse.KeyDown:connect(function(key) if debounce == true then debounce = false wait(5) debounce = true return end end) mouse.KeyDown:connect(function(key) if debounce then --your script end end)
(I just did something similar but my main function is a little different so idk if it will work)