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
1 | Points_To_Give = 100 -- Player Points that will be given. |
2 |
3 | script.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 |
9 | end ) |
Output: 14:13:18.518 - Workspace.PointsAwarder.Script:9: ')' expected (to close '(' at line 3) near 'end'
Thanks!
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.
01 | Points_To_Give = 100 -- Player Points that will be given. |
02 | debounce = false |
03 | script.Parent.Touched:connect( function (hit) |
04 |
05 | if hit.Parent:FindFirstChild( "Humanoid" ) and game:GetService( "PointsService" ):GetAwardablePoints() > Points_To_Give and debounce = = false then |
06 | debounce = true |
07 | local P = game.Players:GetPlayerFromCharacter(hit.Parent) |
08 |
09 | game:GetService( "PointsService" ):AwardPoints(P.userId, Points_To_Give) |
10 |
11 | wait( 3 ) |
12 | debounce = false |
13 | end |
14 | end ) |
You had an extra end on line 7. The fixed script would look like this:
1 | Points_To_Give = 100 -- Player Points that will be given. |
2 |
3 | script.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 ) |
+1 if this helped!