Hi i have problem about destroying clone in workspace, when i destroy, it impact to original one in server storage
and when i click again it say this
here my script
local tool = script.Parent
local canDamage = true
local left = script.Left
local Right = script.Right
local canSwing = true
local MagicPaper = game.ServerStorage.MagicPaper:Clone()
local KnockBack = Instance.new("BodyVelocity")
local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if not humanoid then
return
end
if humanoid.Parent ~= tool.Parent and canDamage then
humanoid:TakeDamage(10)
canDamage = false
MagicPaper:Destroy()
else
return
end
canDamage = false
end
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)
end
end
tool.Activated:Connect(slash)
MagicPaper.Touched:Connect(onTouch)
1 Like
It doesn’t impact the original in ServerStorage. You destroyed the clone in onTouch, but try to access the same clone in slash. Maybe you could clone it again after you destroy the clone?
if humanoid.Parent ~= tool.Parent and canDamage then
humanoid:TakeDamage(10)
canDamage = false
MagicPaper:Destroy()
MagicPaper = game.ServerStorage.MagicPaper:Clone() -- clone the MagicPaper again
else
return
end
2 Likes
It worked but there still have a problem another time that i click body velocity don’t go to magic paper
1 Like
When the MagicPaper was destroyed it’s children (BodyVelocity) was destroyed too, you need to make a new one there. You can do it like this:
let KnockBack = Instance.new("BodyVelocity") -- new knockback instance
KnockBack.Parent = MagicPaper -- part is the target of the knockback/ the opponent
-- ...
which eliminates the need for the KnockBack at the top of the script.
2 Likes
oh and i have another question can you help?
in the first magic paper it have touch interest
but next one dont have touch interest
how i can fix it?
local tool = script.Parent
local canDamage = true
local left = script.Left
local Right = script.Right
local canSwing = true
local MagicPaper = game.ServerStorage.MagicPaper
tool.Activated:Connect(function()
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
if workspace:FindFirstChild("MagicPaper") then
workspace:FindFirstChild("MagicPaper"):Destroy()
end
local MagicPaperClone = MagicPaper:Clone()
MagicPaperClone.Parent = workspace
MagicPaperClone.Position = script.Parent.Parent.HumanoidRootPart.Position
MagicPaperClone.Orientation = script.Parent.Parent.HumanoidRootPart.Orientation
local TT = Instance.new("TouchTransmitter")
TT.Parent = MagicPaperClone
MagicPaperClone.Touched:Connect(function(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if not humanoid then
return
end
if humanoid.Parent ~= tool.Parent and canDamage then
humanoid:TakeDamage(10)
canDamage = false
MagicPaperClone:Destroy()
else
return
end
canDamage = false
end)
local KnockBack = Instance.new("BodyVelocity")
KnockBack.Parent = MagicPaperClone --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
task.wait(5)
end
end)
it said Unable to create an Instance of type “TouchTransmitter” how do i fix it?
local tool = script.Parent
local canDamage = true
local left = script.Left
local Right = script.Right
local canSwing = true
local MagicPaper = game.ServerStorage.MagicPaper
local TT = game.ServerStorage.MagicPaper
tool.Activated:Connect(function()
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
if workspace:FindFirstChild("MagicPaper") then
workspace:FindFirstChild("MagicPaper"):Destroy()
end
local MagicPaperClone = MagicPaper:Clone()
MagicPaperClone.Parent = workspace
MagicPaperClone.Position = script.Parent.Parent.HumanoidRootPart.Position
MagicPaperClone.Orientation = script.Parent.Parent.HumanoidRootPart.Orientation
local TTClone = TT:Clone()
TTClone.Parent = MagicPaperClone
MagicPaperClone.Touched:Connect(function(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if not humanoid then
return
end
if humanoid.Parent ~= tool.Parent and canDamage then
humanoid:TakeDamage(10)
canDamage = false
MagicPaperClone:Destroy()
else
return
end
canDamage = false
end)
local KnockBack = Instance.new("BodyVelocity")
KnockBack.Parent = MagicPaperClone --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
task.wait(5)
end
end)
Try this, place a “TouchTransmitter” instance inside the “ServerStorage” folder.
Okay, so a “TouchTransmitter” instance is automatically created when “Touched” fires, you don’t need to create one, use this instead:
local tool = script.Parent
local canDamage = true
local left = script.Left
local Right = script.Right
local canSwing = true
local MagicPaper = game.ServerStorage.MagicPaper
tool.Activated:Connect(function()
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
if workspace:FindFirstChild("MagicPaper") then
workspace:FindFirstChild("MagicPaper"):Destroy()
end
local MagicPaperClone = MagicPaper:Clone()
MagicPaperClone.Parent = workspace
MagicPaperClone.Position = script.Parent.Parent.HumanoidRootPart.Position
MagicPaperClone.Orientation = script.Parent.Parent.HumanoidRootPart.Orientation
MagicPaperClone.Touched:Connect(function(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if not humanoid then
return
end
if humanoid.Parent ~= tool.Parent and canDamage then
humanoid:TakeDamage(10)
canDamage = false
MagicPaperClone:Destroy()
else
return
end
canDamage = false
end)
local KnockBack = Instance.new("BodyVelocity")
KnockBack.Parent = MagicPaperClone --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
task.wait(5)
end
end)
Alright Thank you! it worked AAAAAAAAAAAAAAAAAAAAAAAAAAAAA