Wait are you handling the tools on the client or on the server?
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.
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.
30characterssssssssssssssssssssssssssssssssssssssssssssss
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.