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

Why does this point system freeze at 1?

Asked by 4 years ago
Edited 4 years ago

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.

0
Remove is deprecated. Use Destroy instead. PrismaticFruits 842 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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.

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. Nozo_rapsocooz 16 — 4y
0
To not reset the point back to zero, I deleted line 10. But, the point kept increasing rapidly. What should I do? Nozo_rapsocooz 16 — 4y
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. radiant_Light203 1166 — 4y
0
It still produces the same result. Nozo_rapsocooz 16 — 4y
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. radiant_Light203 1166 — 4y
Ad

Answer this question