Please help me, whats wrong with this script?
1 | local player = game.Players.LocalPlayer |
2 | local mouse = player:GetMouse() |
3 | mouse.KeyDown:connect( function (key) |
4 | if key = = "z" then |
5 | game.ReplicatedStorage.OpeOpe.Barrier 1 :Clone().Parent = game.Workspace [ player.Name.. "Skills" ] |
6 | game.Workspace [ player.Name.. "Skills" ] .Barrier 1. CFrame = CFrame.new(player.Character.HumanoidRootPart.Position.X,player.Character.HumanoidRootPart.Position.Y,player.Character.HumanoidRootPart.Position.Z) |
7 | wait( 5 ) |
8 | end |
9 | 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.
01 | local usable = true |
02 | local player = game.Players.LocalPlayer |
03 | local mouse = player:GetMouse() |
04 | mouse.KeyDown:connect( function (key) |
05 | if key = = "z" then |
06 | usable = false |
07 | game.ReplicatedStorage.OpeOpe.Barrier 1 :Clone().Parent = game.Workspace [ player.Name.. "Skills" ] |
08 | game.Workspace [ player.Name.. "Skills" ] .Barrier 1. CFrame = CFrame.new(player.Character.HumanoidRootPart.Position.X,player.Character.HumanoidRootPart.Position.Y,player.Character.HumanoidRootPart.Position.Z) |
09 | wait( 5 ) |
10 | usable = true |
11 | end |
12 | end ) |
Do this:
01 | local debounce = true |
02 |
03 | mouse.KeyDown:connect( function (key) |
04 | if debounce = = true then |
05 | debounce = false |
06 | wait( 5 ) |
07 | debounce = true |
08 | return |
09 | end |
10 | end ) |
11 |
12 | mouse.KeyDown:connect( function (key) |
13 | if debounce then |
14 | --your script |
15 | end |
16 | end ) |
(I just did something similar but my main function is a little different so idk if it will work)