local Car = script.Parent.Parent.Object.Value
local Player = game:GetService("Players").LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
Car:GetPropertyChangedSignal("Name"):Connect(function()
if Car.Name == "Destroyed" and Car.Destroyed.Value == false then
local Amount = 100
local Event = ReplicatedStorage.Event
Event:FireServer(Player, Amount)
Car.Destroyed.Value = true
else
return
end
end)
RemoteEvent.OnServerEvent listeners automatically receive the Player instance of the client that called RemoteEvent:FireServer. Additional arguments follow:
local function OnServerEvent(Player, ...)
With the additional Player instance passed, Amount gets occupied by the instance.