01 | local USI = game:GetService( "UserInputService" ) |
02 | local damage = 50 |
03 | local Handle = script.Parent.Handle |
04 | local rep = game.ReplicatedStorage |
05 | local CanSprint = rep.BoolValues.CanSprint |
06 |
07 | script.Parent.Equipped:Connect( function (equip) |
08 | local plr = equip.Parent |
09 | local Humanoid = plr:FindFirstChild( "Humanoid" ) |
10 |
11 | Handle.Transparency = 1 |
12 |
13 | USI.InputBegan:Connect( function (input) |
14 | local keycode = input.KeyCode |
15 | if keycode = = Enum.KeyCode.F then |
Instead of
1 | local plr = equip.Parent |
2 | local Humanoid = plr:FindFirstChild( "Humanoid" ) |
try doing
1 | local plr = game:GetService( "Players" ).LocalPlayer |
2 | local Humanoid = plr.Character:FindFirstChild( "Humanoid" ) |
1 | local humanoid = game.Players.LocalPlayer.Character:WaitForChild( "Humanoid" ) |
try doing this:
1 | script.Parent.Equipped:Connect( function () |
2 | local plr = script.Parent.Parent |
3 | local Humanoid = plr:WaitForChild( "Humanoid" , 0.1 ) |
4 | -- rest of your code here |
5 | end ) |