Ello Developers
I made this script below this text (Local-script, Inside of a button) where pressing It with a certain Item equipped will fire an event, currently, I tried doing so but It cannot fire It
Script:
01 | local Player = game:GetService( "Players" ).LocalPlayer |
02 | local Debounce = false |
03 |
04 | script.Parent.MouseButton 1 Click:Connect( function () |
05 | if not Debounce then |
06 | Debounce = true |
07 | if Player.Backpack:WaitForChild( "Crossbow" ) then |
08 | Player.Backpack:WaitForChild( "Crossbow" ).SpecialAbility 1 :FireServer() |
09 | wait( 3 ) |
10 | Debounce = false |
11 | end |
12 | end |
13 | end ) |
If a tool is "equipped" by a player it will be parented to their character rather than their backpack. So you just have to replace Player.Backpack with Player.Character.
(Also use FindFirstChild instead of WaitForChild, WaitForChild is used to wait for something to appear rather than to check if it exists.)
1 | if Player.Character:FindFirstChild( "Crossbow" ) then |
2 | Player.Character.Crossbow.SpecialAbility 1 :FireServer() |
3 | wait( 3 ) |
4 | Debounce = false |
5 | end |