Sword not damaging cloned model

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!

Roblox Client-Server Model. The server cannot see the object that the client cloned and therefore cannot deal damage to an object that does not exist on its environment. You need to do the cloning from the server. If it’s important that the training dummy stays local then you will additionally need to change your hit detection to the client and implement server-side validation and damaging capabilities.

2 Likes