Hello everyone, my name is spideyalvaro999
So I’m going to explain the situation. I made a collectable coin, that when the player touch it, it disapear and add 1 to you amount of money. So the problem here is that it works really fine but I created a shop that when you buy something, it rest you the money of the object, but when you collect a coin, the amount does not continue since you purchased the item, but continues from your quantity before buying the item and you sum one, which makes you get the item for free. Here I let you all the stuff
The collectable coin script:
local coinPart = script.Parent local toggle = false local amount = 1 coinPart.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil and not toggle then coinPart.Sound:Play() toggle = true local player = game.Players:GetPlayerFromCharacter(hit.Parent) local leaderboard = player:FindFirstChild("hellstats") local coins = leaderboard.HellCoins coins.Value = coins.Value + amount local coinClone = coinPart:Clone() coinPart:Destroy() wait(10) coinClone.Parent = workspace toggle = false end end)
The close button from the shop:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteEvent = ReplicatedStorage:WaitForChild("OpenHellRE") RemoteEvent.OnClientEvent:Connect(function() script.Parent.Parent.Visible = true end) script.Parent.Parent.CloseButton.MouseButton1Click:Connect(function() script.Parent.Parent.Visible = false end)
The Buy Button Script:
local player = game:GetService("Players").LocalPlayer local RemoteEvent = game.ReplicatedStorage.HellCoins script.Parent.MouseButton1Click:Connect(function(click) if player.leaderstats.Points.Value >= 700 then RemoteEvent:FireServer(700, "CrimsonSword") end end)
The Server Script(leaderstats):
local replicatedStorage = game:GetService("ReplicatedStorage") local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("CashSaveSystem") local RemoteEvent = game.ReplicatedStorage.HellCoins game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder",player) leaderstats.Name = "hellstats" local points = Instance.new("IntValue",leaderstats) points.Name = "HellCoins" points.Value = ds:GetAsync(player.UserId)or 0 ds:SetAsync(player.UserId, points.Value) points.Changed:connect(function() ds:SetAsync(player.UserId, points.Value) end) end) game.Players.PlayerRemoving:Connect(function(player) ds:SetAsync(player.UserId, player.leaderstats.point.Value) end) RemoteEvent.OnServerEvent:Connect(function(player, Value, Item) -- player.leaderstats.Points.Value = player.leaderstats.Points.Value - Value game.ReplicatedStorage.Library[Item]:Clone().Parent = player:WaitForChild("Backpack") end)
I thought abut a remote event that tells the server all the stuff, but I dont know where to put it.
I hope you can help me. Thanks for spending your time helping
Spideyalvaro999