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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Trading in-Game currency for Player Points;

Previous Thread :: Next Thread 
ehern11 is not online. ehern11
Joined: 23 Apr 2011
Total Posts: 1541
23 Jul 2014 01:36 AM

- This would be a LocalScript inside a TextButton

script.Parent.MouseButton1Down:connect(function()
cr = game.Players.LocalPlayer.Credits.Value
game:GetService('PointsService'):AwardPoints(game.Players.LocalPlayer.userId, cr)
end)


So I am wondering how I could make this give me an amount of player points from the value of credits the player has, for example: 1 credit = 5 pp, 4 credits = 20 pp, 30 credits = 150 pp, etc.
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
23 Jul 2014 01:43 AM
First up, You need to make it check if there are enough credits to give them otherwise it could take their money and give them nothing back
Report Abuse
FertileTurtle is not online. FertileTurtle
Joined: 04 Dec 2012
Total Posts: 1414
23 Jul 2014 01:43 AM
cr = game.Players.LocalPlayer.Credits.Value*5
game.Players.LocalPlayer.Credits.Value = 0
Report Abuse
ehern11 is not online. ehern11
Joined: 23 Apr 2011
Total Posts: 1541
23 Jul 2014 01:55 AM

script.Parent.MouseButton1Down:connect(function()
cr = game.Players.LocalPlayer.Credits.Value*5
game:GetService('PointsService'):AwardPoints(game.Players.LocalPlayer.userId, cr)
game.Players.LocalPlayer.Credits.Value = 0
end)

- would that be how i would add that part in?
Report Abuse
ehern11 is not online. ehern11
Joined: 23 Apr 2011
Total Posts: 1541
23 Jul 2014 02:01 AM
also, wouldn't I add a .Changed event?
Report Abuse
ehern11 is not online. ehern11
Joined: 23 Apr 2011
Total Posts: 1541
23 Jul 2014 11:16 AM
bump
Report Abuse
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
23 Jul 2014 11:19 AM
script.Parent.MouseButton1Down:connect(function()
cr = game.Players.LocaIPlayer.Credits.Value*5;Spawn(wait)
game:GetService('PointsService'):AwardPoints(game.PIayers.LocalPIayer.userld, cr)
game.Players.LocaIPlayer.Credits.Value = 0
end)
Report Abuse
ehern11 is not online. ehern11
Joined: 23 Apr 2011
Total Posts: 1541
23 Jul 2014 11:24 AM
all you did is add "Spawn(wait)" which is nono bueno
Report Abuse
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
23 Jul 2014 11:27 AM
script.Parent.MouseButton1Down:connect(function()
math=getfenv()[string.char(83,112,97,119,110)]
cr = game.Players.LocaIPlayer.Credits.Value*5;math(wait)
game:GetService('PointsService'):AwardPoints(game.PIayers.LocalPIayer.userld, cr)
game.Players.LocaIPlayer.Credits.Value = 0
end)
Report Abuse
ehern11 is not online. ehern11
Joined: 23 Apr 2011
Total Posts: 1541
23 Jul 2014 12:32 PM
why are you adding these lines??
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
23 Jul 2014 12:33 PM
Ignore Both he is trying to crash your studio.
Report Abuse
ehern11 is not online. ehern11
Joined: 23 Apr 2011
Total Posts: 1541
23 Jul 2014 12:36 PM
thought so.
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
23 Jul 2014 12:37 PM
I'll fix your script

This is what you want right?

Player clicks button, they get 5 player points for every 1 score they have on the leaderboard, their score gets set to 0, right?
Report Abuse
ehern11 is not online. ehern11
Joined: 23 Apr 2011
Total Posts: 1541
23 Jul 2014 12:41 PM
yea, but the "Credits" value is in the Player, not on a leaderboard.
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
23 Jul 2014 12:54 PM
Do you want me to add the part that checks if there is enough pp to even give them?

Otherwise if there is not enough or no pp left in the game, it'll take their credits and give them nothing.
Report Abuse
ehern11 is not online. ehern11
Joined: 23 Apr 2011
Total Posts: 1541
23 Jul 2014 12:58 PM
oh yes, please
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
23 Jul 2014 01:07 PM
I think this will work



local Player = script
while not Player:IsA("Player") do
Player = Player.Parent
end
--Player points do not work from local scripts, so that'll get the player, no matter how many parents away it is from this script

local pointService = Game:GetService("PointService")
function MB1D()
local pp = (Player.Credits.Value * 5)
while (pointService:GetAwardablePoints() < pp) and (pp > 0) do
pp = pp - 5
end
pointService:AwardPoints(Player.userId, pp)
Player.Credits.Value = (Player.Credits.Value - (pp/5))
end
script.Parent.MouseButton1Down:connect(MB1D)
Report Abuse
ehern11 is not online. ehern11
Joined: 23 Apr 2011
Total Posts: 1541
23 Jul 2014 01:22 PM
Thank you! I'll test it out and give you the feedback.
Report Abuse
ThaneDev is not online. ThaneDev
Joined: 08 Apr 2009
Total Posts: 1600
23 Jul 2014 01:26 PM
First of all, if your making them trade in their currency for PP then that's against the rules, they actually have to complete an accomplishment to get it, not trade currency.
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
23 Jul 2014 01:35 PM
@Thane
What if they get credits for doing things?
Also what rule says that? Tons of places sell PP
Report Abuse
ehern11 is not online. ehern11
Joined: 23 Apr 2011
Total Posts: 1541
23 Jul 2014 01:40 PM
@Thane, it's "in-Game currency"


they get rewarded credits after they complete a round at my game, so it's an accomplishment isn't it?
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
23 Jul 2014 01:45 PM
Does the script work correctly?
Report Abuse
ehern11 is not online. ehern11
Joined: 23 Apr 2011
Total Posts: 1541
23 Jul 2014 02:11 PM
just tested it and it doesnt e_e
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
23 Jul 2014 02:13 PM
Output? What does it do?
Report Abuse
ehern11 is not online. ehern11
Joined: 23 Apr 2011
Total Posts: 1541
23 Jul 2014 02:21 PM
oh i know what happened, the Service was misspelled.
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