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)

game.Players.PlayerAdded:connect(function(player)
int = Instance.new("BoolValue")
int.Name = "Finished"
int.Parent = player
int.Value = false
end) --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

script.Parent.Touched:connect(function(player) --Part Touched, calls player
int = hit.Parent:FindFirstChild("Finished") --Checks for BoolValue
if int ~=nil and int.Value == false then --Checks if the BoolValue is there and if it's false
game:GetService("PointsService"):AwardPoints(player.userId,100) --Awards 100 Points
int.Value = true --Avoids another 100PP's
end
wait(1) --Waits 1 second before giving another 100PPs if they haven't got them yet
end) --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.

local on=false
script.Parent.Touched:connect(function(hit) --Part Touched, calls player
    if on==false then
        on=true
        if hit.Parent:FindFirstChild("Humanoid")  then
            local plr=game.Players:GetPlayerFromCharacter(hit.Parent)
            local int=plr:findFirstChild("Finished")
            if int ~=nil and int.Value == false then
                game:GetService("PointsService"):AwardPoints(player.userId,100) 
                int.Value = true --Avoids another 100PP's
            end
        end
    end
    wait(1) --Waits 1 second before giving another 100PPs if they haven't got them yet
    on=false
end) --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....

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 - 1 then
        local P = game.Players:GetPlayerFromCharacter(hit.Parent)
        if not P:FindFirstChild("Has Been Given " .. Points_To_Give) then
            game:GetService("PointsService"):AwardPoints(P.userId, Points_To_Give)
            Marker = Instance.new("Flag", P)
            Marker.Name = "Has Been Given " .. Points_To_Give
        end
    end
end)

Answer this question