So I am making a Tycoon and I am adding perks that adds stats like Cash, Health, and Speed but I am having a problem. My Cash Dev product script works fine that isn't the problem its the one that adds speed. So when it is bought it gives you the selected amount of speed and when you die it is gone which is how I wanted it. But when I rejoined I quickly noticed that you get all of the speed that you payed for back which is practically really frustrating considering I CANT fix it at all.People have told me to use Bool value but in that aspect I am very lost and dont get it. Another guy said that the game is thinking that they are buying it again so it gives them the speed again and to add a Bool value. I ask them how I would do this but they explain it and I dont get it. It seems to short and not well said on how to do it... I am in deer need for a solution! Please help if you can!
Here is my script for the speed just in case it is needed:
local developerProduct = 20433249 local speedInc = 15
Game:GetService("MarketplaceService").ProcessReceipt = function(receipt) if receipt.ProductId == developerProduct then for i,v in pairs(game.Players:GetPlayers()) do if v.userId == receipt.PlayerId then if v.Character and v.Character:FindFirstChild("Humanoid") then v.Character.Humanoid.WalkSpeed = v.Character.Humanoid.WalkSpeed + speedInc end end end end end
A player added function is basically a function that triggers when a player is added. So for example, one way of doing a player added function(The way I prefer) is like this:
game.Players.PlayerAdded:connect(function(player) --do stuff end)
The "player" in line one of the code, is referring to the player that has been added, and no other player.
"--do stuff" is referring to the code that you would execute AFTER the player has joined. For example, creating a number value in the the player's instance in game.Players could be done like this:
game.Players.PlayerAdded:connect(function(player) --Listens for a player to join the server local x = Instance.new("NumberValue") --Creates a number value instance x.Parent = player --Parents the number value to the player that just joined x.Value = 100 --Sets the number values value to 100 end) --Ends the block of code
If you are serious about scripting, and really want to learn, but don't know where to start, refer to http://wiki.roblox.com/index.php?title=Scripting for more help.
If you have any more question, PM me on ROBLOX @DenialOfRetribution