my leaderboard script that gives money :

local Datastore = game:GetService("DataStoreService"):GetDataStore("Money")

  

game.Players.PlayerAdded:Connect(function(player)

  

local Key = "Player-ID:" .. player.UserId

  

local leaderstats = Instance.new("Folder", player)

  

leaderstats.Name = "leaderstats"

  

local Money = Instance.new("NumberValue", leaderstats)

  

Money.Name = "Money"

  

game:GetService("ReplicatedStorage"):WaitForChild("Money").OnServerEvent:Connect(function()

  

Money.Value = Money.Value + game.Workspace.Base.Seller.seller.ironore1.Value

end)

  

-- GetAsync

  

local GetSave = Datastore:GetAsync(Key)

  

if GetSave then

  

Money.Value = GetSave[1]

  

print("Data loaded for " .. player.Name)

  

else

  

local Numbers = {Money.Value}

  

Datastore:SetAsync(Key, Numbers)

  

print("Data Saved for " .. player.Name)

  

end

  

end)

  

game.Players.PlayerRemoving:Connect(function(player)

  

local Key = "Player-ID:" .. player.UserId

  

local ValuesToSave = {player.leaderstats.Money.Value}

  

Datastore:SetAsync(Key, ValuesToSave)

  

print("Data Saved for " .. player.Name)

  

end)

my local script that fires the event:

script.Parent.Touched:Connect(function(hit)

if hit.Parent:FindFirstChildOfClass("Part") then

game:GetService("ReplicatedStorage").Money:FireServer()

end

end)

how can i make this only give the player that sells the "ore" the money and not everyone else aka how can i make it only give the owner of the seller money

2 comments

0

You didn't state who you are giving the value to, saying "Money.Value = Money.Value" will just give everyone that. Instead say Player.Money.Value

0

so player.Money.Value = player.Money.Value + game.Workspace.Base.Seller.seller.ironore1.Value.Value will only give the money to player who sells