Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)




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!

This discussion is preserved as it was. New answers, comments, and votes are closed.