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

How can I award playerpoints at the end of an obby WITHOUT it spamming points?

Asked by
Retroc 35
10 years ago

Hiya all. I am currently working on an obby that awards 100 player points at the end of the obby. Just to let you guys know, this is a button you press. I already have the scripts that make it change your team (To the first stage) and kill you so you spawn there. I've experimented and used a lot of help from a great scripter, but neither of us can get it to work. Now, the script doesn't even award points. It used to awards a lot of bulk 100 player points when stepped on.

This is the script that is in Workspace that gives the player a value (Thanks to fahmisack123)

1game.Players.PlayerAdded:connect(function(player)
2int = Instance.new("BoolValue")
3int.Name = "Finished"
4int.Parent = player
5int.Value = false
6end) --Put this in Workspace...

This is the script that is in the part that you step on to get player points. Just to classify, this part that is stepped on is IN workspace and NOT in a model, if that is needed. Again, thanks to fahmisack123

1script.Parent.Touched:connect(function(player) --Part Touched, calls player
2int = hit.Parent:FindFirstChild("Finished") --Checks for BoolValue
3if int ~=nil and int.Value == false then --Checks if the BoolValue is there and if it's false
4game:GetService("PointsService"):AwardPoints(player.userId,100) --Awards 100 Points
5int.Value = true --Avoids another 100PP's
6end
7wait(1) --Waits 1 second before giving another 100PPs if they haven't got them yet
8end) --Put this in the part that gets touched

Thanks for the help! I will make sure to give whoever helps a ton of credit. Also, these scripts are NOT in a local script.

2 answers

Log in to vote
0
Answered by 10 years ago

You're searching the Character for the bool, but it's in the Player.

01local on=false
02script.Parent.Touched:connect(function(hit) --Part Touched, calls player
03    if on==false then
04        on=true
05        if hit.Parent:FindFirstChild("Humanoid"then
06            local plr=game.Players:GetPlayerFromCharacter(hit.Parent)
07            local int=plr:findFirstChild("Finished")
08            if int ~=nil and int.Value == false then
09                game:GetService("PointsService"):AwardPoints(player.userId,100)
10                int.Value = true --Avoids another 100PP's
11            end
12        end
13    end
14    wait(1) --Waits 1 second before giving another 100PPs if they haven't got them yet
15    on=false
16end) --Put this in the part that gets touched

This answer is brought to you by Chipio Industries

Ad
Log in to vote
0
Answered by 10 years ago

This is the way I would do it without values....

01Points_To_Give = 100  -- Player Points that will be given.
02 
03script.Parent.Touched:connect(function(hit)
04    if hit.Parent:FindFirstChild("Humanoid") and game:GetService("PointsService"):GetAwardablePoints() > Points_To_Give - 1 then
05        local P = game.Players:GetPlayerFromCharacter(hit.Parent)
06        if not P:FindFirstChild("Has Been Given " .. Points_To_Give) then
07            game:GetService("PointsService"):AwardPoints(P.userId, Points_To_Give)
08            Marker = Instance.new("Flag", P)
09            Marker.Name = "Has Been Given " .. Points_To_Give
10        end
11    end
12end)

Answer this question