I made a shuriken, and when I throw it, it kills me instead. Help! There's no errors either. Just an infinite yield on ":WaitForChild()"
local Tool = script.Parent.Parent
local Player = game:GetService("Players").LocalPlayer
--local Animations = Tool.Animations
--local ThrowAnimation = Animations.ThrowAnimation
local Debounce = false
local ThrowSound = Tool.Handle.Throw
local Mouse = Player:GetMouse()
local PlayAnimation = game:GetService("ReplicatedStorage"):WaitForChild("PlayAnimation")
local StopAnimation = game:GetService("ReplicatedStorage"):WaitForChild("StopAnimation")
Tool.Activated:Connect(function()
if Debounce == false then
Debounce = true
ThrowSound:Play()
Throw()
wait(0.201)
Debounce = false
end
end)
function Throw()
local NewProjectile = Tool.Handle:Clone()
NewProjectile.Parent = workspace
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = NewProjectile
BodyVelocity.Velocity = Player.Character.Head.CFrame.lookVector*90
NewProjectile.Touched:Connect(function(hit)
if hit and hit.Parent:WaitForChild("Humanoid") then
hit.Parent.Humanoid:TakeDamage(25)
NewProjectile:Destroy()
end
end)
end

1 comment
You're supposed to use a FindFirstChild, not WaitForChild. You are waiting for a humanoid which does not exist, and therefore yields the script. Also, you should connect Throw to the Touched event