So im making a racing game and using a remote event to start the cooldown that is fired when the player gets in the car. Though when i try to write it i get the error mentioned in the title.
Here is the script:
Server:
local remoteEvent = game.ReplicatedStorage:WaitForChild("CooldownEvent")
local function fireToLocalPlayer(player)
remoteEvent:FireClient(player)
end
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if seat.Occupant then
fireToLocalPlayer(player)
end
end)
Local Script:
local remoteevent = game.ReplicatedStorage.CooldownEvent
remoteevent.OnClientEvent:Connect(function()
print"CoolDownEvent Recieved"
end)
local seat = script.Parent
local Players = game:GetService("Players")
local remoteEvent = game.ReplicatedStorage:WaitForChild("CooldownEvent")
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if seat.Occupant then
local Player = Players:GetPlayerFromCharacter(seat.Occupant.Parent)
print(Player.Name)
remoteEvent:FireClient(Player)
end
end)