ServerScriptService.Leaderboard:17: attempt to index local 'player' (a number value)
local datastore = game:GetService("DataStoreService") local ds1 = datastore:GetDataStore("CashSaveSystem") game.Players.PlayerAdded:Connect(function(player) local folder = Instance.new("Folder",player) folder.Name = "leaderstats" local cash = Instance.new("IntValue",folder) cash.Name = "Cash" cash.Value = ds1:GetAsync(player.UserId) or 0 ds1:SetAsync(player.UserId, cash.Value) cash.Changed:Connect(function() ds1:SetAsync(player.UserId, cash.Value) end) game.ServerStorage.Give.Event:Connect(function(player,Amount) if player.Name == player.Name then cash.Value = cash.Value + Amount end end) end)
Filtering Enabled on
Script in ServerScriptService
BindableEvent in ServerStorage
BindableEvent rename to Give
I do it a lots of time but it not work.
I script 2 script
It not give me the Cash when I kill NPC.
I open output and click the only error one.
and it go to the box up there.
There are a few issues with your code.
you are obviously not parsing the correct arguments. If the script believes that the player is the number, then you obviously have not passed the player as an argument to the event.
the event overrides the
player variable in the script, meaning the if statement will always return true, and every person will always receive the cash. Rename the variable on the event arguments to something else to fix this.
So, you just need to check your script which fires the event and rename a variable, and hopefully everything should be working.
If I helped you, remember to mark this as the correct answer and thumbs up. :)