Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I locate Humanoid in this script ?

Asked by 3 years ago
01local USI = game:GetService("UserInputService")
02local damage = 50
03local Handle = script.Parent.Handle
04local rep = game.ReplicatedStorage
05local CanSprint = rep.BoolValues.CanSprint
06 
07script.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
View all 33 lines...

3 answers

Log in to vote
0
Answered by 3 years ago

Instead of

1local plr = equip.Parent
2local Humanoid = plr:FindFirstChild("Humanoid")

try doing

1local plr = game:GetService("Players").LocalPlayer
2local Humanoid = plr.Character:FindFirstChild("Humanoid")
0
didnt work :( monstermarwan -3 — 3y
0
also is it a localscript or a server script? Mathilinium 112 — 3y
0
server script monstermarwan -3 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
1local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
0
This is in a local script, btw. RazorXX2 24 — 3y
Log in to vote
0
Answered by
NGC4637 602 Moderation Voter
3 years ago

try doing this:

1script.Parent.Equipped:Connect(function()
2    local plr = script.Parent.Parent
3    local Humanoid = plr:WaitForChild("Humanoid",0.1)
4    -- rest of your code here
5end)

Answer this question