Hi i have problem about touch interest,
I create tool that when you click it shoot a part and when it touch humanoidrootpart it will destroy
first time that i shoot it have touch interest
but i shoot second one it dont have touch interest and it dont deal any damage
First time that i shoot
Next one
The Script
local tool = script.Parent
local canDamage = false
local left = script.Left
local Right = script.Right
local canSwing = true
local MagicPaper = game.ServerStorage.MagicPaper:Clone()
local KnockBack = Instance.new("BodyVelocity")
local function slash()
local str = Instance.new("StringValue")
local hum = script.Parent.Parent:WaitForChild("Humanoid")
local humleft = hum:LoadAnimation(script.Left)
local humright = hum:LoadAnimation(script.Right)
local hummiddle = hum:LoadAnimation(script.Middle)
if script.Parent.Slash.Value == 1 and canSwing then
local Speed = 100
local Force = 50000
local TotalForce = Force
MagicPaper.Parent = game.Workspace
MagicPaper.Position = script.Parent.Parent.HumanoidRootPart.Position
MagicPaper.Orientation = script.Parent.Parent.HumanoidRootPart.Orientation
KnockBack.Parent = MagicPaper --part is the target of the knockback/ the opponent
KnockBack.MaxForce = Vector3.new(TotalForce,TotalForce,TotalForce)
KnockBack.Velocity = script.Parent.Parent:FindFirstChild("HumanoidRootPart").CFrame.LookVector * Speed
wait(5)
return
end
return
end
local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if not humanoid then
return
end
if humanoid.Parent ~= tool.Parent then
humanoid:TakeDamage(10)
MagicPaper:Destroy()
MagicPaper = game.ServerStorage.MagicPaper:Clone()
KnockBack = Instance.new("BodyVelocity") -- new knockback instance
KnockBack.Parent = MagicPaper
return
else
return
end
end
tool.Activated:Connect(slash)
MagicPaper.Touched:Connect(onTouch)