I am a novice developer although I have developed several games for last 6 months.
Now I am developing a new obby game and what I want to realize is:
When a player touches a checkpoint (spawn) object, the object color changes and a sound beeps for a few seconds, in addition to display of a small heart and awarded currency amount above the object for a second, while the given currency amount is reflected on a leaderstats only once per one spawn object in a game session.
You can use bindable events to communicate between server to server or client to client scripts. Though why can’t you just give the currency in the checkpoint script by getting the player and the respective value you want to change?
leaderstats is a folder found in the player. So to access it you need to find it in the player instead. I’m not sure if you have defined the player? If not, you can get the player from the touched event like so:
local players = game:GetService('Players')
local debounce = false
if not debounce then
local player = players:GetPlayerFromCharacter(hit.Parent)
local leaderstats = player:FindFirstChild('leaderstats')
local money = leaderstats:FindFirstChild('Love')
money.Value += amount
debounce = true
Also, I notice that you have defined a few variables at the top of your script that you should consider removing because they will throw errors, as you can’t define them like that:
The local player can only fetched through a local script
The leaderstats variable can only fetched when you’re getting the player.