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

Why won't this script work?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

Hello. I'm making a shooting game with 5 teams, & whatever team gets a certain number of points win. If someone on a team kills someone from another team (like if a blue player kills a yellow player), that team gets 1 point (team blue). Here's my script:

-- declare service
local PointsService = Game:GetService("PointsService")

-- Bind function to player added event
game.Players.PlayerAdded:connect(function(player)
    -- Get total number of points this game has already awarded to the player
    local universeBalance = PointsService:GetGamePointBalance(player.userId)
    -- Check if the player hasn't gotten any points yet. If true, award the points.
    if ( universeBalance == 0) then
        PointsService:AwardPoints(player.userId, 1)
    end
end)

-- Bind function to when points are successfully awarded
PointsService.PointsAwarded:connect(function(userId, userBalanceinUni, userBalance)
    -- Show message indicating that a player has gotten points
    local message = Instance.new('Message', game.Workspace)
    message.Text = "Point awarded to " .. userId .. ". This player now has " .. userBalance .. " points total!"
    wait(5)
    message:Destroy()
end)

--Add this to your weapon script and call it when a player is killed
local PointsService = game:GetService("PointsService")

function awardPoints(creator)
    if time() - lastAwardedTime < 5 then 
            return
    else
        lastAwardedTime = time()
        PointsService:AwardPoints(creator.Value, 1)
    end
end
--// In the future, please put your code in a code block. All you have to do is click the blue button in edit mode, and put your code between the lines.

I already made the teams & spawn locations; but for some reason, my script won't work. Please help, this is my first game. Also, what server should it be on? Thanks.

0
Is the part which has a comment which says, "Add this to your weapon script and call it when a player is killed" in the same script? Pyrondon 2089 — 8y
0
Yes it is. Why? should I take it out? HaiseSasakiCCGninja 0 — 8y

Answer this question