|
| 09 Jan 2017 11:10 AM |
*This is a re-post because i worded the last one incorrectly....
For some reason, this shop buying script doesn't work unless played through studio. When pressed, The button subtracts the money as if the item was bought and everything, but just does not give you the actual bought item.
Would i have to edit this script in any way to make it properly working in mobile? Thanks! Help is greatly appreciated:)
local cost = 20
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function() local Leaderstats = player:FindFirstChild("leaderstats") if Leaderstats then local money = Leaderstats:FindFirstChild("Money") if money.Value >= cost then money.Value = money.Value - cost local item = game.ServerStorage.ShopCatalog.DogePet:Clone() item.Parent = player.Backpack end end end) |
|
|
| Report Abuse |
|
|
C_Sharper
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 6405 |
|
|
| 09 Jan 2017 11:27 AM |
I spotted the error.
You can't access ServerStorage with a LocalScript. Try putting the item into ReplicatedStorage instead, or use a server script.
^_^ |
|
|
| Report Abuse |
|
|
|
| 09 Jan 2017 11:29 AM |
| You can press ## in Play Mode to open up the Dev Console which shows all the errors client+serversided. Idk if you can get this on mobile. But if you say it only works in studio worth doing this on a pc. Cause I don't see anything wrong with the script above. So I'd think it was an error elsewhere. Ohhhhh wait nvm. If you have FE on, you can't access Serversided objects from client scripts. Such as server storage. So you'd have to do what you're doing with RemoteEvents. To tell a server sided script to give the DogePet to the appropriate player. Google "Scripting Helpers" to find a "better" forum - http://wiki.roblox.com/index.php?title=AllTutorials - http://wiki.roblox.com/index.php?title=API:Class_reference - Google "Programming in Lua" for The book |
|
|
| Report Abuse |
|
|
|
| 09 Jan 2017 11:30 AM |
tfw ROBLOX removes all the reply's formatting. Thanks ROBLOX! :D
Google "Scripting Helpers" to find a "better" forum - http://wiki.roblox.com/index.php?title=AllTutorials - http://wiki.roblox.com/index.php?title=API:Class_reference - Google "Programming in Lua" for The book |
|
|
| Report Abuse |
|
|
|
| 09 Jan 2017 04:45 PM |
| Thanks everyone! Had no clue of the separate functionalities of local and server-sided scripts! :) |
|
|
| Report Abuse |
|
|
|
| 09 Jan 2017 05:06 PM |
I think this is only a restriction when your game is using Filtering Enabled. Of which I suggest almost every game to do.
Google "Scripting Helpers" to find a "better" forum - http://wiki.roblox.com/index.php?title=AllTutorials - http://wiki.roblox.com/index.php?title=API:Class_reference - Google "Programming in Lua" for The book |
|
|
| Report Abuse |
|
|