Wait are you handling the tools on the client or on the server?
Why are tools/pets in replicated storage invisible to others but not the user that owns them?
Also why are you taking the money away on the client that’s a mistake because exploiters can change stuff on the client also you should be handling it on the server and checking the price you know? I saw the person’s post above I’d suggest you do what he showed you.
Do you know how I would handle this on the server, I am new to scripting.
Ok, so there’s actually a better way of going through this. Remote events are able to transport information via client to server or vice versa. Follow these steps for a better solution:
- Make a folder in the ReplicatedStorage (if you haven’t already) and name it “Items”. This will be where all of the items are stored.
- Make a folder in the shop GUI of all the item purchase buttons (make sure the button’s name matchesthe item’s name in the Items folder). In each button, insert an IntValue and name it “Price”. From there, set its value to the price you want for that specific item.
- Inside that folder in the shop gui, insert a local script with this code:
local remote = game.ReplicatedStorage.RemoteEvent --you can change this local buttons = script.Parent for _, v in pairs(buttons:GetChildren()) do if not v:IsA("LocalScript") then v.MouseButton1Click:Connect(function() remote:FireServer(v.Name, v.Price.Value) end) end end)
- Insert a server script into ServerScriptStorage, and type in the code:
local remote = game.ReplicatedStorage.RemoteEvent --you can change this remote.OnServerEvent:Connect(function(player, item, price) if player.leaderstats.Coins.Value >= price then player.leaderstats.Coins.Value -= price game.ReplicatedStorage.Items[item]:Clone().Parent = player:WaitForChild("Backpack") end end)
Where do I place these scripts? In the shop?
I stated in my directions where to place the scripts. If you want, I can make a demo place
Okay so instead of cloning it on the client clone it to that player on the server. Also handle buying on the server as well you can use a remote event or you can use a remote function if you want to return a string/bool value showing if the player has purchased it and it was complete.
He can handle it in a table for a module script. Also he can fire the remote event to the server without a module script since he really isn’t doing any extra stuff.
Yes, this will be great since I am new to scripting in roblox.
Also @dinogaming8 do you have a script to handle the pets to go around the player?
Yes, the pet has a script to follow the player.
Alright, so I made a demo place, showing how I would go about doing this. Seen in this video, I only use 1 script (for both client and server) to control each item:
If you want to download the place, here it is: ItemsExample.rbxl (34.7 KB)
Thank you so much for this, to make it easier, should I just delete my current shop GUI and make a whole new one? The shop also controls the gamepasses.
You can make a seperate folder for the gamepasses, and use a system similar in terms of client to server.
I would like to thank you so much for taking your time to help me fix this problem. It is really nice to have someone that is skilled to help someone new fix their errors.
No problem. Don’t forget to mark as a solution so people know this has been solved
Alright, will do.
I came back and I’m reviewing this why are you not even checking the price on the server you are sending it from the client exploiters can edit things like this.