Ovations, everyone. I was writing a script, where it renames your tool when you touch something. My tool is called Mop and it is still renaming it to Mop | 3/3 .. What is the problem with my script? I would be glad if anyone could help me.
script.Parent.Touched:connect(function(h) if h.Parent.Name == "Mop" then h.Parent.Name = "Mop | 1/3" elseif h.Parent.Name == "Mop | 1/3" then h.Parent.Name = "Mop | 2/3" elseif h.Parent.Name == "Mop | 2/3" then h.Parent.Name = "Mop | 3/3" end end)
Every single help is appreciated, thank you!
Since .Touched events fire pretty fast youll need a debounce and TouchEnded.
local deb script.Parent.Touched:connect(function(h) if not deb then deb = true if h.Parent.Name == "Mop" then h.Parent.Name = "Mop | 1/3" elseif h.Parent.Name == "Mop | 1/3" then h.Parent.Name = "Mop | 2/3" elseif h.Parent.Name == "Mop | 2/3" then h.Parent.Name = "Mop | 3/3" end end end) script.Parent.TouchEnded:Connect(function(h) if string.match(h.Parent.Name, "^Mop") then --checks if the tool's name starts with mop deb = false end end)