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

1Points_To_Give = 100  -- Player Points that will be given.
2 
3script.Parent.Touched:connect(function(hit)
4    if hit.Parent:FindFirstChild("Humanoid") and game:GetService("PointsService"):GetAwardablePoints() > Points_To_Give  then
5        local P = game.Players:GetPlayerFromCharacter(hit.Parent)
6            game:GetService("PointsService"):AwardPoints(P.userId, Points_To_Give)
7        end
8    end
9end)

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.

01Points_To_Give = 100  -- Player Points that will be given.
02debounce = false
03script.Parent.Touched:connect(function(hit)
04 
05    if hit.Parent:FindFirstChild("Humanoid") and game:GetService("PointsService"):GetAwardablePoints() > Points_To_Give and debounce == false  then
06debounce = true
07        local P = game.Players:GetPlayerFromCharacter(hit.Parent)
08 
09        game:GetService("PointsService"):AwardPoints(P.userId, Points_To_Give)
10 
11    wait(3)
12debounce = false
13    end
14end)
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:

1Points_To_Give = 100  -- Player Points that will be given.
2 
3script.Parent.Touched:connect(function(hit)
4    if hit.Parent:FindFirstChild("Humanoid") and game:GetService("PointsService"):GetAwardablePoints() > Points_To_Give  then
5        local P = game.Players:GetPlayerFromCharacter(hit.Parent)
6        game:GetService("PointsService"):AwardPoints(P.userId, Points_To_Give)
7    end
8end)

+1 if this helped!

Answer this question