Hi all
I was trying to fire a event on server side but this error popped up: FireClient: player argument must be a Player object
Even after idefined the player in the script.
The script:
local player = game.Players.LocalPlayer
local Car = game.Workspace.Car
local Destination1 = game.Workspace.Car1
local Destination2 = game.Workspace.Car2
local TweenService = game:GetService("TweenService")
local CarTweenInfo = TweenInfo.new(5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0)
local CarTween = TweenService:Create(Car, CarTweenInfo, {CFrame = Destination1.CFrame})
local CarTween2 = TweenService:Create(Car, CarTweenInfo, {CFrame = Destination2.CFrame})
game.ReplicatedStorage.CarTrigger.OnServerEvent:Connect(function()
CarTween:Play()
game.Workspace["Car Engine"]:Play()
game.ReplicatedStorage.CutsceneTrigere:FireClient(player)
CarTween2:Play()
wait(4.8)
game.Workspace["Car Engine"].Looped = false
game.Workspace["Car Stop 1.1"]:Play()
script.Parent.Tween.Disabled = true
end)
I cant fix this problem and am hoping someone can help.
Thank You
you can’t use local player in a server script
and the error is from you not setting a variable in your onserverevent function for the player which is the first argument sent over by the client
if any other part of this needs to do something client side you may want to recode it
but here is a version with player declared
--local player = game.Players.LocalPlayer -- you can't get the local player on the server since there isn't one
local Car = game.Workspace.Car
local Destination1 = game.Workspace.Car1
local Destination2 = game.Workspace.Car2
local TweenService = game:GetService("TweenService")
local CarTweenInfo = TweenInfo.new(5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0)
local CarTween = TweenService:Create(Car, CarTweenInfo, {CFrame = Destination1.CFrame})
local CarTween2 = TweenService:Create(Car, CarTweenInfo, {CFrame = Destination2.CFrame})
game.ReplicatedStorage.CarTrigger.OnServerEvent:Connect(function(player) -- when a client fires the server the player is always the first argument sent over to the server you need a variable for it
CarTween:Play()
game.Workspace["Car Engine"]:Play()
game.ReplicatedStorage.CutsceneTrigere:FireClient(player)
CarTween2:Play()
wait(4.8)
game.Workspace["Car Engine"].Looped = false
game.Workspace["Car Stop 1.1"]:Play()
script.Parent.Tween.Disabled = true
end)