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
I'm not too faimilar with clone but i believe you had that wrong, I am using a new part as a substitute. Also you needed to add a maxForce and a new cframe for the part, let me know if this works for you! :)
local Tool = script.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 = Instance.new('Part')--Tool.Handle:Clone() game.Debris:AddItem(NewProjectile) local BodyVelocity = Instance.new("BodyVelocity",NewProjectile) BodyVelocity.Parent = NewProjectile BodyVelocity.Velocity = Player.Character.Head.CFrame.lookVector*90 BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge) NewProjectile.Parent = game.Workspace -- added at a lower line NewProjectile.CFrame = Player.Character.UpperTorso.CFrame *CFrame.new(0, 0, -9) wait(0.5) -- dont like the spam of the parts NewProjectile.Touched:Connect(function(hit) if hit and hit.Parent:WaitForChild("Humanoid") then hit.Parent.Humanoid:TakeDamage(25) NewProjectile:Destroy() end end) end