Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can i make this only give the local player money?

Asked by 5 years ago

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

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 CardJester 15 — 5y
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 Gameplayer365247v2 1055 — 5y

Answer this question