So I’m trying to make my sword damage a model with a humanoid but it doesn’t work. The problem is probably either the model which is cloned from replicated storage or the sword script. The sword works on models that I don’t clone. I already spent about half a week and I don’t know how to fix it. I’m pretty new to coding so my code is kind of messy.
(Server Script)
This is my sword script
local tool = script.Parent
local blade = script.Parent.Blade
local damage = false
print("damage = false")
local function slash()
print("tool activated")
damage = true
print("damage = true")
local str = Instance.new("StringValue")
str.Name = "toolanim"
str.Value = "Slash"
str.Parent = tool
local function onTouch(partOther)
local humanOther = partOther.Parent:FindFirstChild("Humanoid")
if not humanOther then return end
if humanOther.Parent == tool then return end
if damage == true then
humanOther:TakeDamage(5)
print("tool on touch")
damage = false
print("damage = false")
end
end
tool.Blade.Touched:Connect(onTouch)
wait(0.5)
damage = false
print("damage = false")
end
tool.Activated:Connect(slash)
(Local Script)
This is my cloning script
local td1 = game.ServerStorage.TrainingDummy1:Clone() -- This clones the object
td1.Parent = workspace
Any help would be appreciated, ty!