Local Script:
local mouse = game.Players.LocalPlayer:GetMouse()
local throwshurikenAnim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.ThrowShuriken)
script.Parent.Activated:Connect(function()
if not game.Workspace:FindFirstChild(script.Parent.Parent.Name.."Shuriken") then
throwshurikenAnim:Play()
throwshurikenAnim.Stopped:Connect(function()
game.ReplicatedStorage.Message:FireServer("ThrowShuriken", script.Parent.Handle, mouse.Hit.p)
end)
end
end)
ServerScript:
game.ReplicatedStorage.ThrowShuriken.OnServerEvent:Connect(function(player, message, handle, mousepos)
local debounce = true
local shuriken = handle:Clone()
shuriken.Name = player.Name.."Shuriken"
shuriken.Parent = workspace
shuriken.CanCollide = false
shuriken.Position = player.Character.RightHand.Position
handle.Transparency = 1
local bodyVelocity = Instance.new("BodyVelocity", shuriken)
bodyVelocity.Velocity = (mousepos - shuriken.Position).unit*50*Vector3.new(1,0,1)
local bodyAngularVelocity = Instance.new("BodyAngularVelocity", shuriken)
bodyAngularVelocity.AngularVelocity = Vector3.new(0, 120, 0)
debris:AddItem(shuriken,10)
shuriken.Touched:Connect(function(a)
print(a.Parent.Name..", "..a.Name)
if a.Parent.Name ~= player.Name and a.Name ~= "Handle" and a.Name ~= shuriken.Name and debounce == true then
debounce = false
if a.Parent:FindFirstChild("Humanoid") then
a.Parent.Humanoid:TakeDamage(10)
shuriken:Destroy()
else
shuriken.Anchored = true
print("Anchored")
end
end
end)
spawn(function()
repeat wait() until not game.Workspace:FindFirstChild(shuriken.Name)
handle.Transparency = 0
end)
end)
When the handle clones the second time, 2 shurikens appear. When it clones the third time, 3 shurikens appear. But I only want 1 to appear each time. How can I fix this?
