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

Coins awarded if certain level is reached not working?

Asked by 4 years ago

So, I'm trying to make a script that (once placed in a part) will disappear and give the player coins/points, when touched. I was able to make it so the coins/points were awarded, but I wanted to make it so that the player has to be a certain level to have the script work, For example, a level 1 player can collect the green coin which awards 10 points, and a level 15 player can collect the red coin which awards 100 points, but the level 1 player cannot. Also the level 15 player can still collect the green coins as well.

This is what I have so far:

debounce = false
script.Parent.Touched:connect(function(part)
if debounce == false then
local h = part.Parent:findFirstChild("Humanoid")
if h then
    local level = plyr.leaderstats.Level
    level.Value = 1
    if level.Value then
local plyr = game.Players:findFirstChild(part.Parent.Name)
local coins = plyr.leaderstats.Coins
coins.Value = coins.Value + 5
local points = plyr.leaderstats.Points
points.Value = points.Value + 5
debounce = true
end
end
else
wait(0.1)
script.Parent:remove()
end

I know some of it is probably wrong, if anyone could help me that would be great! Thank you!

Answer this question