Sorry for unclear question but, I am trying to make something where it detects if its been touched by a tool
script.Parent.Touched:Connect(function(Hit) if Hit.Parent.Name == '(name)' then end end)
but after it hits it, I want it to plus a value, and after the value reaches 20, it doesn't plus it anymore, anybody able to help?
You can make an int value, and then if it's touched then that value = value + 1, you can repeat this action using the repeat
function in Roblox Studio and then use the Until
function in Roblox Studio. If the value is 20 then that Until function will stop anything.
script.Parent.Touched:Connect(function(hit) if game.Players:GetPlayerFromCharacter(hit.Parent) then local RootPart = hit.Parent:FindFirstChild("HumanoidRootPart") if RootPart then repeat script.Parent.Value = script.Parent.Value + 1 until script.Parent.Value == 20 end end end)
If you want it to be tocuhed by a tool use this script:
function tch(h) if (h.Parent.Name == "ToolName") then script.Parent.Value = script.Parent.Value +1 end end script.Parent.Touched:connect(tch)