generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: i want to give 1 player point if someone buy this

Previous Thread :: Next Thread 
PikachuFan48 is not online. PikachuFan48
Joined: 04 Aug 2013
Total Posts: 2144
06 Jun 2014 03:00 PM
Help me fix this script pls


local buyButton = script.Parent.Button.Button
local productId = ID
local Plr = script.Parent.Parent

buyButton.MouseButton1Click:connect(function()
Game:GetService("MarketplaceService"):PromptProductPurchase(Plr, productId)
end)

local MarketplaceService = Game:GetService("MarketplaceService")

MarketplaceService.PromptProductPurchaseFinished:connect(function(userId, productId, isPurchased)
if isPurchased then
--What happens after purchase
end
end)

local buyButton2 = script.Parent.Button2.Button
local productId2 = ID

buyButton2.MouseButton1Click:connect(function()
Game:GetService("MarketplaceService"):PromptProductPurchase(Plr, productId2)
end)

MarketplaceService.PromptProductPurchaseFinished:connect(function(userId, productId2, isPurchased2)
if isPurchased2 then
--What happens after purchase
end
end)
Report Abuse
PikachuFan48 is not online. PikachuFan48
Joined: 04 Aug 2013
Total Posts: 2144
06 Jun 2014 03:04 PM
Im going put id after someone fixes it
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
06 Jun 2014 03:04 PM
What'd wrong with it you idiot
Report Abuse
PikachuFan48 is not online. PikachuFan48
Joined: 04 Aug 2013
Total Posts: 2144
06 Jun 2014 03:06 PM
I don't know how to make it so it gives 1 player point.
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
06 Jun 2014 03:09 PM
-- declare service
local PointsService = Game:GetService("PointsService")

-- Bind function to player added event
game.Players.PlayerAdded:connect(function(player)
-- Get total number of points the game has available
local pointsToAward = PointsService:GetAwardablePoints()
-- Get total number of points this game has already awarded to the player
local universeBalance = PointsService:GetGamePointBalance(player.userId)
-- Check if the game has points to award and if the player hasn't gotten any points yet.
-- If both are true, then give the player a point.
if ( pointsToAward > 0 and universeBalance == 0) then
-- pcall here, as AwardPoints *will throw an error* if another server has awarded the
-- points that were available between us checking how many were available and
-- us actually awarding the points. There is currently no way to avoid this pcall,
-- whenever you AwardPoints you should always wrap it in a pcall.
pcall(function()
PointsService:AwardPoints(player.userId, 1)
end)
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)





look over it

the main line that gives you it is
PointsService:AwardPoints(player.userId, 1)
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
06 Jun 2014 03:09 PM
prompted.Game:getservice("LeadersStats").PlayerPoints = prompted.Game:getservice("LeadersStats").PlayerPoints + 1
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
06 Jun 2014 03:11 PM
kev that will add a fake playerpoint value if the player has a leaderboard with "Payerpoint" as the name
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
06 Jun 2014 03:12 PM
or I might have read that wrong
Report Abuse
PikachuFan48 is not online. PikachuFan48
Joined: 04 Aug 2013
Total Posts: 2144
06 Jun 2014 03:36 PM
do i put it between if isPurchased then?
Report Abuse
PikachuFan48 is not online. PikachuFan48
Joined: 04 Aug 2013
Total Posts: 2144
06 Jun 2014 03:43 PM
because im trying to do if isPurchased then give player point if available
Report Abuse
PikachuFan48 is not online. PikachuFan48
Joined: 04 Aug 2013
Total Posts: 2144
06 Jun 2014 03:47 PM
is this how it works? if not right fix it pls
local buyButton = script.Parent.Button.Button
local productId = 20042710
local Plr = script.Parent.Parent

buyButton.MouseButton1Click:connect(function()
Game:GetService("MarketplaceService"):PromptProductPurchase(Plr, productId)
end)

local MarketplaceService = Game:GetService("MarketplaceService")

MarketplaceService.PromptProductPurchaseFinished:connect(function(userId, productId, isPurchased)
if isPurchased then PointsService:AwardPoints(player.userId, 1)
--What happens after purchase
end
end)

local buyButton2 = script.Parent.Button2.Button
local productId2 = ID

buyButton2.MouseButton1Click:connect(function()
Game:GetService("MarketplaceService"):PromptProductPurchase(Plr, productId2)
end)

MarketplaceService.PromptProductPurchaseFinished:connect(function(userId, productId2, isPurchased2)
if isPurchased2 then
--What happens after purchase
end
end)
Report Abuse
PikachuFan48 is not online. PikachuFan48
Joined: 04 Aug 2013
Total Posts: 2144
06 Jun 2014 03:53 PM
Also can anyone tell me how to put in game that a certain purchase gives player point to player point total in game not to a player
Report Abuse
PikachuFan48 is not online. PikachuFan48
Joined: 04 Aug 2013
Total Posts: 2144
06 Jun 2014 03:55 PM
nvm it might be automatic
Report Abuse
PikachuFan48 is not online. PikachuFan48
Joined: 04 Aug 2013
Total Posts: 2144
07 Jun 2014 02:06 AM
bump
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image