Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does this point system freeze at 1?

This is the entire script I place in ServerScriptService

local function grape()
    local GrapeCopy = Grape:Clone()
local function getfat(b)
  local parent = b.Parent
    local humanoid = parent:FindFirstChild("Humanoid")
if game.Players:GetPlayerFromCharacter(parent) then
GrapeCopy.Transparency = 1
local player = game.Players:GetPlayerFromCharacter(parent)
        
        player.leaderstats.Coins.Value =0
        player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1
        GrapeCopy:Remove()
        wait(5)
        
end 
end
GrapeCopy.Touched:Connect(getfat)
wait(0.4)

end
 
while true do
    grape()
    wait(1)
end

Problem: When I played it, the point increased only once. If I touch another grape, the point stood at 1. If you want the full script and more details, DM me on discord: Starlight#7272.

1 comment

0

Remove is deprecated. Use Destroy instead.

1 answer

On line ten you keep resetting the player's points back to zero, so even though the player gains a point on the next line he will still have one point.

I'm not sure why you've reset the points value but it will be at zero by default when the player joins when his points folder is created.

5 comments

0

If I didn’t set that, the point would increase rapidly. For example, when character touches a grape, the point should have increased by 1 but it increased by 10 or more.

0

To not reset the point back to zero, I deleted line 10. But, the point kept increasing rapidly. What should I do?

0

It's because the grapeCopy() you made with touched should be destroyed, it's still there and will keep repeating its touch function. If you want it to work only once then use Grape:Destroy() to remove it so the touch function fires once; you'll just respawn it later on.

0

It still produces the same result.

0

Either use a debounce function or increase the respawn time. The grapes are produced every one second and the touch function will occur every one second not five.

This discussion is preserved as it was. New answers, comments, and votes are closed.