I’m trying to make a system where whenever a user touches a part, it adds 100 to their “currency” value, but when a player does it a second time, it gives them 200 more instead of 100, and then when a player does it a third time it gives them 300, and so on. I’ve never experienced this issue before and I’m not sure how to fix it. Could anyone help?
script:
FinishPart.Touched:Connect(function(Touched)
if Touched.Parent:FindFirstChild("Humanoid") or Touched.Parent.Parent:FindFirstChild("Humanoid") then
FinishPart.CanTouch = false
local Character = Touched.Parent
local Player = game:GetService("Players"):GetPlayerFromCharacter(Character)
wait(1)
local DataStore2 = require(1936396537)
local award = -100
local currencyStore = DataStore2("currency", Player)
currencyStore:Increment(-award)
ObbyMinigame.Parent = game.ReplicatedStorage
GameHosted.Value = false
FinishPart.CanTouch = true
end
well, i could be wrong but
finishpart’s cantouched is set to false, as to not trigger the award again, correct? but then after waiting 1 second, it is set to cantouch true again
so maybe youre actually just triggering it more than once on accident…?
I don’t think that’s it because the value increases by 100 exactly each time, and even if I destroy the part giving the reward after it’s first touched it still does the same thing.