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

How can I get this player points awarding script to work?

Asked by
Retroc 35
10 years ago

Hiya all. I have a script here that is placed inside a part called PointsAwarder and when the part is stepped on, it awards points. I can't get it to work, and I was hoping someone could help out. This is the current script that is placed inside the part

Points_To_Give = 100  -- Player Points that will be given.

script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and game:GetService("PointsService"):GetAwardablePoints() > Points_To_Give  then
        local P = game.Players:GetPlayerFromCharacter(hit.Parent)
            game:GetService("PointsService"):AwardPoints(P.userId, Points_To_Give)
        end
    end
end)


Output: 14:13:18.518 - Workspace.PointsAwarder.Script:9: ')' expected (to close '(' at line 3) near 'end'

Thanks!

2 answers

Log in to vote
1
Answered by
Thetacah 712 Moderation Voter
10 years ago

TurboFusion is right...though I suggest making a debounce variable, that way you want get several hundreds for stepping on the Part. I rarely use Debounces, so you might want to mess with the true/false debounce variable until you get it.

Points_To_Give = 100  -- Player Points that will be given.
debounce = false
script.Parent.Touched:connect(function(hit)

    if hit.Parent:FindFirstChild("Humanoid") and game:GetService("PointsService"):GetAwardablePoints() > Points_To_Give and debounce == false  then
debounce = true
        local P = game.Players:GetPlayerFromCharacter(hit.Parent)

        game:GetService("PointsService"):AwardPoints(P.userId, Points_To_Give)

    wait(3)
debounce = false
    end
end)




Ad
Log in to vote
1
Answered by 10 years ago

You had an extra end on line 7. The fixed script would look like this:

Points_To_Give = 100  -- Player Points that will be given.

script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and game:GetService("PointsService"):GetAwardablePoints() > Points_To_Give  then
        local P = game.Players:GetPlayerFromCharacter(hit.Parent)
        game:GetService("PointsService"):AwardPoints(P.userId, Points_To_Give)
    end
end)

+1 if this helped!

Answer this question