Tool Not Working

Hey there, I Am Trying to Call a function When a tool Is Activated By Such A Script.

local Tool = script.Parent

function onTouch(OtherPart)
	local HumanOther = OtherPart.Parent:FindFirstChild("Humanoid")
	if not HumanOther then return end
	
	if HumanOther.Parent == Tool then return end
	if HumanOther:FindFirstChild("NotToDamage") then print("Not To Damage") return end
	
	print("Damaging")
	HumanOther:TakeDmg(8)	
	
end

local function Slash()
	
	print("Activated")
	
	local String = Instance.new("StringValue")
	String.Parent = Tool
	String.Name = "toolanim"
	String.Value = "Slash"
	
end

Tool.Activated:Connect(Slash)
Tool.Handle.Touched:Connect(onTouch)

The Script is Placed Inside the Tool And The Above Script ONLY Works if I Put the Tool into Starter Pack.

If i Put the Tool into Starter Pack and Play the Game, I Get the Tool and It Prints Activated in the Output. But If i Clone the Tool from A Place (Such as Replicated Storage) to the Player’s Backpack, The Tool Does Not Work.

The Script is A SCRIPT And Not A Local Script

Hello there. I tried your script and it works. Were you cloning the tool from the client or the server?

The Client? Is there anything wrong with cloning it on the client?

Yes there is. Since you are making it work on a server script cloning in the client will create some problems. If you clone it from the server there’ll be no issues

1 Like

Thanks it Worked! I was cloning it on the client before that was the issue.

1 Like