Script problem!

  1. What do you want to achieve?
    I want to my code work !
  2. What is the issue?
    I don’t understand why it doesn’t work !
  3. What solutions have you tried so far?
    Client side :
Players.PlayerRemoving:Connect(function()
	Player.CharacterRemoving:Connect(function()
		FDW = FDW + 10
		RemoteEventFDW:FireServer(FDW)
	end)
end)

Server side :

RemoteEventFirstTime.OnServerEvent:Connect(function(Player, FDW)
	DataStoreFDW:SetAsync(Player.UserId, FDW)
end)

The error :

Argument 2 missing or nil
1 Like

You forgot to put Player as an argument hers:

Players.PlayerRemoving:Connect(function(Player)
	Player.CharacterRemoving:Connect(function()
		FDW = FDW + 10
		RemoteEventFDW:FireServer(FDW)
	end)
end)

Tho I dont see any reason to do that.

You could simply do all the process on the server

1 Like

Thank but it doesn’t work again that put me the same error in the output ! :neutral_face:

What is “FDW”? Could you show us

1 Like

“FDW” is the currency of the game ! :grin:

Try put .Value when adding 10 to it.

1 Like

Players.PlayerRemoving:Connect(function(Player)
	Player.CharacterRemoving:Connect(function()
		FDW.Value += 10
		RemoteEventFDW:FireServer(FDW.Value)
	end)
end)

1 Like

It is not a value object it is a variable ! :thinking:

could you try to print FDW? same with Player.UserId

1 Like

That print “nil” in the output ! :wink:

im guessing FDW printed nil right?

1 Like

Yes it is ! :grin: (548469594251515)

wait so is that the value for FDW you got?

1 Like

its possible that the player might already be removed when its fired so the .UserId is nil

1 Like

“FDW” is nil and the other is the player UserID so I don’t know why “FDW” is nil ! :neutral_face:

nevermind could you try printing the FDW on the place that fires the remote?

1 Like

its because you never predefined it yet…

1 Like

Oh sorry I made a mistakes in my script it work now :sweat_smile: :

  1. Client side :
Players.PlayerRemoving:Connect(function()
	Player.CharacterRemoving:Connect(function()
		FDW = FDW + 10
		RemoteEventFDW:FireServer(FDW)
	end)
end)

Server side :

RemoteEventFDW.OnServerEvent:Connect(function(Player, FDW)
	DataStoreFDW:SetAsync(Player.UserId, FDW)
end)

It’s work but your right the remote event doesn’t work because it isn’t fired at time ! :neutral_face: