Shop and sell script are not working help!

I recently started scripting and made a shop for my simulator game the shop works and all but once i get some strength with the item i bought and sell it for some reason it gives all the coins back that i used to but the item, here is my buy item script i also put my sell script in case that helps (1st picture is sell script)


Any help is appreciative!

1 Like

Scripts look fine , Any output?

1 Like

no nothing comes up in the output which is why im confused

1 Like

Is your buy script is a LocalScript?, If yes use RemoteEvent

1 Like

Does it detect the click/touch? Try do print(“Yes”) after it detects a click or a touch event.

1 Like

Actually, Its a LocalScript use RemoteEvent It may help you out only for The 2nd script

1 Like

How can input this into my script sorry im very beginner at this

1 Like

This is LocalScript :

local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
 if plr.leaderstats.Coins.Value >= 30 then
game.ReplicatedStorage.Buy:FireServer()
end
end)

The Script :

game.ReplicatedStorage.Buy.OnServerEvent:Connect(function(plr)
 plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value - 30
game.ReplicatedStorage.Tools.White:Clone().Parent = plr:WaitForChild("Backpack")
end)

The last script should be normal Script and put this one in side ServerScriptService

Oh, Insert RemoteEvent and Name it into “Buy” and move this inside ReplicatedStorage

if There’s something went wrong im sorry because im on Mobile

2 Likes

Wow thank you been trying to fix this for 2 days straight you are my savior!

2 Likes