I'm doing a simulator game all ok so far. But when I go to sell something ex: I want to sell clouds to earn points, it works all right but when I buy something in the store I lose 1500 points when I sell clouds again my points return to normal as if I had not spent the points
Anyone know how to solve I'll leave the scripts of the place of sale and store
Sell Place Script
local Part = script.Parent
Part.Touched:Connect(function(HIT)
local H = HIT.Parent:FindFirstChild("Humanoid")
if H then
local player = game.Players:GetPlayerFromCharacter(HIT.Parent)
if player then
local leaderstats = player:WaitForChild("leaderstats")
local Currency = leaderstats.Points -- Ponga el nombre de el leaderstats
local Selling = leaderstats.Clouds -- Ponga el nombre de el leaderstats
if Selling.Value > 0 then
Currency.Value = Currency.Value + Selling.Value -- This 1 means multiple you can change it to whatever you want
Selling.Value = 0
end
end
end
end)
Store Script
local player = game.Players.LocalPlayer
local currency = player:WaitForChild("leaderstats").Points -- leaderstat 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)
end
end
end
end)
this store script is filtered by IntValue and Remove Event
