Why the coins are going back to normal?

yep it should look like that
[30 char]

1 Like

why there’s a red line under value? btw sorry if i am wasting your time
script7help

1 Like

Oh, you can just include a “local” before “Value” if you desire. It will still run fine even if you don’t.

1 Like

when i buy something the money don’t decrerase :I

1 Like

Are there any errors in the output, and are you buying the specific one that you scripted?

1 Like

maybe i found the issue. i will reply if i found it

1 Like

alright. just tell me if it’s right.

Value = Value - player.PlayerGui.Shop.Frame.ScrollingFrame.Cost.Value

1 Like

Yep that is right. Just make sure that the value is set to what you want it to subtract

1 Like

here’s a video

Ah, so their’s two problems here.

  1. The cost value is not changing for the GUI in the startergui
  2. The value is changing client side(I assume) and the server still thinks it is 0.
    Local script
local player = game.Players.LocalPlayer
local button = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")

button.MouseButton1Click:Connect(function()
    remoteEvent:FireServer(player.PlayerGui.Shop.Frame.ScrollingFrame.Cost.Value)
end)

Server script

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")

remoteEvent.OnServerEvent:Connect(function(player,Cost)
     Value = player.leaderstats.Coins.Value
     Value = Value - Cost
end)

What this does is it passes the amount the item costs from the client to the server. The server then uses that value to subtract from the player’s value

should i only copy and paste? or change something?

You can just copy and paste it. I had to edit to clarify where you paste each one into

in the server script how does the game know what cost is? sorry if i’m asking these things but i’m new : P

The local script is passing the value to the server script. In the video you showed, the local script only knows that it costs 12 coins, because when you clicked on an item, it changed the value locally. The thing in the FireServer parenthesis is the cost of the item. The server script then takes it, and then subtracts it from the player’s coins

soo is this normal?
scrip8help

Oh! My bad. I messed up while pasting and editing the code. I have edited it now, so you can go ahead and change it

local script
script9help
server script
script10help

Yep, that should work as intended!

i will do a video video video video. should i go in a team test server?

1 Like

i don’t understand