Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

When you touch a part it adds a point, but when you touch it again it wont give you a point?

Asked by 3 years ago
Edited 3 years ago

Hello! this is Jaison here and I was wondering if someone could help me fix my script. What I am trying to do in this script is when you touch a part you earn a point, but when you touch it again it wont give you a point here's the code:

local wins = game.Players.leaderstats.wins local player = game.Players.LocalPlayer local debounce = false local mouse = player:GetMouse() local G_ = script.Parent

G_.Touched:Connect(function(hit) while wait() do if hit.Parent == player.Character then if not debounce then debounce = true

            wins.Value = wins.Value ~= 1
            G_.TouchEnded:Connect(function()
                debounce = false
            end)
        end
    end
end

end)

You can DM me on discord JDev#4583

0
can you please edit it and format it properly, i might be able to help then WeaponisedPenguins 97 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Try this:

function onTouch(hit)
    if game.Players:FindFirstChild(hit.Parent.Name) ~= nil then
        char = game.Players:FindFirstChild(hit.Parent.Name)
        char.leaderstats.wins.Value +=1
        script.Disabled = true
    end
end

script.Parent.Touched:Connect(onTouch)

Put it in a normal script in the brick you want. Oh also you dont need anything else

0
tysm dude! jaisonDXYX 24 — 3y
Ad

Answer this question