local plr = game:GetService(“Players”)
script.Parent.Touched:Connect(function(obj)
if obj.Parent:FindFirstChild(“HumanoidRootPart”) then
local n = obj.Parent.Name
local localp = plr:WaitForChild(n)
local Clicks = localp.leaderstats.Clicks
Clicks.Value += 10
script.Enabled = false
script.Parent.Transparency = 1
wait(30)
script.Parent.Transparency = 0
script.Disabled = false
end
end)
local player = game:GetService(“Players”)
script.Parent.Touched:Connect(function(obj)
if obj.Parent:FindFirstChild(“HumanoidRootPart”) then
local n = obj.Parent.Name
local localp = player:WaitForChild(n)
local Clicks = localp.leaderstats.Clicks
Clicks.Value = Clicks.Value + 10
script.Enabled = false
script.Parent.Transparency = 1
wait(30)
script.Parent.Transparency = 0
script.Disabled = false
end
end)
How exactly is it resetting? How are you handling this?
But I would like to point out something here:
Just use :GetPlayerFromCharacter(), it would make this a lot easier, and should make this look better
local p = Players:GetPlayerFromCharacter(obj.Parent)
--[[
when a Touched event is activated, it will give you the part that touched
(referred to as 'hit')
which in the case of a Player, it could be a leg, or an Arm
hit.Parent will give you the Potential Model of the Player if they do touch
the part, which is where :GetPlayerFromCharacter() comes in
what this function does is give you the player based on their Character
pretty useful in most cases, but it isnt always perfect, if a player isn't
found, it will return nil, and would cause errors, so secure it with a statement
to check if the Player Actually exists before using it, like the example below
--]]
if p then -- if p, will fire if its a truthy value (not false or nil)
local clicks = p.leaderstats.Clicks
clicks.Value += 10
--// rest of the code
Make sure you dont have any other scripts interfering/resetting your coins value. There doesent seem to be anything wrong in the script itself you showed