Can anyone please solve this, it is in startergui then shop (a screen gui) , then frame, then main (a frame) then item 1 (contains script with code 1), item 2 (contains script with code 2), a serperator ( a frame), a textbutton, and a title. script 3 is in the workspace.
1. script.Parent.MouseButton1Click:connect(function()
local RS = game:GetService("ReplicatedStorage")
local item = RS:WaitForChild("Sword")
local price = 100
local player = game.Players.LocalPlayer
local stats = player:WaitForChild("leaderstats")
if stats.Cash.Value == price then
stats.Cash.Value = stats.Cash.Value - price
local cloned = item:Clone()
local cloned2 = item:Clone()
cloned2.Parent = player.Backpack
cloned.Parent = player.StarterGear
end
end)
2. script.Parent.MouseButton1Click:connect(function()
local RS = game:GetService("ReplicatedStorage")
local item = RS:WaitForChild("Rocket Launcher")
local price = 500
local player = game.Players.LocalPlayer
local stats = player:WaitForChild("leaderstats")
if stats.Cash.Value == price then
stats.Cash.Value = stats.Cash.Value - price
local cloned = item:Clone()
local cloned2 = item:Clone()
cloned2.Parent = player.Backpack
cloned.Parent = player.StarterGear
end
end)
3. print("Hello world!")
game.Players.ChildAdded:connect(function(player)
local stats = Instance.new("Model",player)
stats.Name="leaderstats"
local money = Instance.new("IntValue",stats)
money.Name="Cash"
money.Value=30 -- Change Your Starting Money
end)

5 comments
Please make your code into script format using lua button because it is hard to read.
Yuwa I have already did that it started out with that amount of cash but still it didn't work
How about the
if player.Cash.Value == price thenpart? Also, since the gui works on client(local script), you have to learn how to use remote events so you can actually change cash of player and give items.Okay thanks I will try it. Sorry I am new to the forum.
So you want us to read all the 3 scripts and then guess where is the problem? Please at least read the output and tell us where is the problem, or if no error message, then tell what's wrong..