Hey There,
Im The_Saver31
So i make this simple LocalScript
:
local player = game.Players.LocalPlayer local currency = player:WaitForChild("leaderstats").Coin -- Currency Name here. local item = script.Parent.Parent.Parent.Item local shop = game.Workspace.Shop local tool = game.ReplicatedStorage:WaitForChild("Tools") script.Parent.MouseButton1Click:Connect(function() if currency.Value >= shop:FindFirstChild("Part"..item.Value).ItemPrice.Value then if player.Backpack:FindFirstChild(shop:FindFirstChild("Part"..item.Value).ItemName.Value) == nil then if shop:FindFirstChild("Part"..item.Value) then currency.Value = currency.Value - shop:FindFirstChild("Part"..item.Value).ItemPrice.Value script.Parent.Text = "Bought" script.Parent.BackgroundColor3 = Color3.new(0.7,0.7,0.7) script.Parent.Shadow.BackgroundColor3 = Color3.new(0.5,0.5,0.5) game.ReplicatedStorage.ShopBuy:FireServer(item.Value) wait() currency.Value = currency.Value end end end end)
All Fine! Item cloned, my Coin changed, BUTTT
Here What I Mean:
I Buy Item Priced 100 and my Coin is 200
Item Cloned and my Coi changed to 100
I pick a Coin that will give me 10 Coin
My Coin back to Normal, from 100 to 200 again [+10 because i pick a Coin]
Information:
-Script was a LocalScript
.
Thank's for Reading!
So basically, the only thing that's wrong is that you did the whole thing in a local script. Because the local script is only in charge of everything that only the player can see, such as GUIs, a local script will not change things on the server. To do this, add a remote event to replicated storage and fire it. I also suggest checking the currency again on the server just to make sure the person actually has the cash, so that people who try to hack the game using third party programs don't get the item and have negative cash. I hope this has helped :)