local USI = game:GetService("UserInputService")
local damage = 50
local Handle = script.Parent.Handle
local rep = game.ReplicatedStorage
local CanSprint = rep.BoolValues.CanSprint
script.Parent.Equipped:Connect(function(equip)
local plr = equip.Parent
local Humanoid = plr:FindFirstChild("Humanoid")
Handle.Transparency = 1
USI.InputBegan:Connect(function(input)
local keycode = input.KeyCode
if keycode == Enum.KeyCode.F then
Handle.Transparency = 0
Humanoid.WalkSpeed = 40
CanSprint = false
end
end)
USI.InputEnded:Connect(function(input)
local keycode = input.KeyCode
if keycode == Enum.KeyCode.F then
Handle.Transparency = 0
Humanoid.WalkSpeed = 16
CanSprint = true
end
end)
end)
COMMUNITY QUESTION
How do I locate Humanoid in this script ?
3 answers
Instead of
local plr = equip.Parent
local Humanoid = plr:FindFirstChild("Humanoid")
try doing
local plr = game:GetService("Players").LocalPlayer
local Humanoid = plr.Character:FindFirstChild("Humanoid")
local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
1 comment
0
This is in a local script, btw.
try doing this:
script.Parent.Equipped:Connect(function()
local plr = script.Parent.Parent
local Humanoid = plr:WaitForChild("Humanoid",0.1)
-- rest of your code here
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
didnt work :(
also is it a localscript or a server script?
server script