Ive been trying forever and cant seem to figure out how to add a gamepass multiplier to my game script but this is the code for when teams win
function TeamWon(Message, TeamColor, Points)
msg.Value = Message
getPlayers = Players:getChildren()
for gp=1, #getPlayers do
if getPlayers[gp].TeamColor == BrickColor.new(TeamColor) then
getPlayers[gp].leaderstats.Wins.Value = getPlayers[gp].leaderstats.Wins.Value + 1
getPlayers[gp].leaderstats.Points.Value = getPlayers[gp].leaderstats.Points.Value + PointsAwarded
end
end
end
First you’d want to make the gamepass, then you need to copy the id.
And now let’s get to the coding part, so MarketPlaceService is a service that can be retrieved via game:GetService and is used to prompt gamepasses/developer product and detect whether the player owns the gamepass or not. (more info here: MarketplaceService | Roblox Creator Documentation)
Now, we can use MarketPlaceService: UserOwnsGamePassAsync(UserID,gamepassID) to detect whether the user owns it. So your code should look like this:
local MarketPlaceService = game:GetService("MarketPlaceService")
local gamepassID = 0 --Put the 2x points gamepass id here
function TeamWon(Message, TeamColor, Points)
msg.Value = Message
local getPlayers = Players:getChildren()
for gp=1, #getPlayers do
if getPlayers[gp].TeamColor == BrickColor.new(TeamColor) then
getPlayers[gp].leaderstats.Wins.Value += 1
if MarketPlaceService:UserOwnsGamePassAsync(getPlayers[gp].UserId,gamepassID) then
getPlayers[gp].leaderstats.Points.Value += PointsAwarded*2
else
getPlayers[gp].leaderstats.Points.Value += PointsAwarded
end
end
end
end
Figured out why it wasnt working at first has Place and not place. But for some reason it also gives the player without the gamepass double points as well.
Nice, something’s to keep in mind though, it’s never rude to offer more help, plus a lot of people learn, retain, and better understand concepts using visuals. Also it is easier to explain with a video and go step-by-step.
Also a few things I’d like to comment about your code (yours is fine there’s just some things that can be done better/more efficient and intuitive)
Instead of using a for gp=1,#getPlayers do loop, it is better to use a pairs loop.
for _, currentPlr in ipairs(getPlayers) do
end
Next time try to format your code with indentations too.
That’s it everything else looks fine. I won’t post the edited code here since if that does work for OP you deserve the solution, if you want you can edit your post.