|
| 26 Jul 2017 02:57 PM |
In my game the player can buy a skin and in studio solo they can equip the skin, but in the local server and real server it does not change the Collection Valuable for some reason, even though it takes away your money which it should only do when the transaction is complete.
local player = game.Players.LocalPlayer local leaderboard = player:WaitForChild("Money") local button = script.Parent local price = button:WaitForChild("Price") local pack = player:WaitForChild("BrownRabbit")
button.MouseButton1Click:connect(function() if leaderboard.Bounz.Value >= price.Value then if pack.Collection.Value == 0 then pack.Collection.Value = 1 if pack.Collection.Value == 1 then -- This should mean that it only works when Collection is 1 leaderboard.Bounz.Value = leaderboard.Bounz.Value - price.Value end end end end)
Which should mean that if the Collection value is 1 then it charges, but when I do it in game and not in studio it charges but the value is 0? This is a local script in the Button GUI
If you know the solution please help, thanks
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
Vultorz
|
  |
| Joined: 02 Mar 2015 |
| Total Posts: 2985 |
|
|
| 26 Jul 2017 04:07 PM |
| stop testing in studio, as it runs on the client instead of the server |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2017 04:12 PM |
| I know that but does anyone know how to make it so the collection actually goes to 1. Thanks. It's a complicated thing and it takes the money of the player which should mean that it is 1 but it doesn't. Also it gives out no error. |
|
|
| Report Abuse |
|
|
| |
|
|
| 27 Jul 2017 04:21 AM |
Is the leaderboard an object in the server? If so it is not directly accessible to a local script. You need a remote event or a remote function for it. |
|
|
| Report Abuse |
|
|
spinywind
|
  |
| Joined: 26 Jan 2012 |
| Total Posts: 3580 |
|
|
| 27 Jul 2017 04:23 AM |
Make sure the leaderstats in the player is named "leaderstats" and all of the stats go inside of that object like money, xp, etc.
local Player = game.Players.LocalPlayer local Leaderboard = player.leaderstats:WaitForChild("Money") local Price = button:WaitForChild("Price") local Pack = player:WaitForChild("BrownRabbit")
script.Parent.MouseButton1Click:connect(function() if Leaderboard.Bounz.Value >= price.Value then if Pack.Collection.Value == 0 then Pack.Collection.Value = 1 if Pack.Collection.Value == 1 then Leaderboard.Bounz.Value = Leaderboard.Bounz.Value - price.Value end end end end)
|
|
|
| Report Abuse |
|
|
|
| 27 Jul 2017 04:38 AM |
| I know that but I didn't set the money value to a leaderstat instead I set it as a GUI, will that interfere in any way? Also the money part works and it takes it away from the original amount but the pack.Collection part won't set to 1, it stays at 0. |
|
|
| Report Abuse |
|
|
| |
|
|
| 27 Jul 2017 05:44 AM |
| It's all through Local scripts in GUI and values inside the player. I am so confused as why it will not change the pack. Collections value to 1. |
|
|
| Report Abuse |
|
|
DevJoas
|
  |
| Joined: 17 Dec 2014 |
| Total Posts: 627 |
|
|
| 27 Jul 2017 05:59 AM |
You should not user local scripts for this.
Things like this have to be handled server sided.
LocalScripts are mostly for Animations and making GUI's interactive or getting input from a player.
Do not use LocalScripts to edit values or buy items. |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2017 06:02 AM |
| The problem is the person buys the pack through a GUI. So I cant use normal scripts because I need to access the local player. The thing that has gone wrong is the pack.Collection not changing to 1. I am trying my best to make it right and I am testing my game through servers all the time trying to fix this. |
|
|
| Report Abuse |
|
|
DevJoas
|
  |
| Joined: 17 Dec 2014 |
| Total Posts: 627 |
|
|
| 27 Jul 2017 06:07 AM |
No.
You can use server scripts.
Use a remote function.
http://wiki.roblox.com/index.php?title=Remote_Events_and_Functions |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2017 06:08 AM |
| Ok, I just discovered something which might help. When I try to buy the item twice it does not buy it, which means that the local script has detected that the value Is one, which means that on the Client Side it is one. But when I try to access the data through the server side it says it is zero. How do I get it so the server side can then detect the change of values! |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2017 06:09 AM |
| Oh I just read the remote functions one, thank you very much and I will go through it and see if it will work. I appreciate your help! :) |
|
|
| Report Abuse |
|
|