Hello ! I want to make it so that when the player sits on the seat, the player's camera moves to a share called "Camera1". But I have a problem with the remoteEvent passing from server to client. Apparently, the client does not detect the "FireAllClients" at the remoteEvent. Here is my code:
Server Script :
--The script is into "ServerScriptService" local Seat = game.Workspace.World.SGC.SeatDHD.Seat local RemoteEvent = game.ReplicatedStorage.SeatDhd Seat.Changed:Connect(function() if Seat.Occupant ~= nil then local Player = game.Players:GetPlayerFromCharacter(Seat.Occupant.Parent) RemoteEvent:FireAllClients(Player.Name) end end)
Local Script :
--The script is in the Seat local Seat = script.Parent local RemoteEvent = game.ReplicatedStorage.SeatDhd local Camera = workspace.CurrentCamera local Camera1 = workspace.CameraSeat RemoteEvent.OnServerEvent:Connect(function(Player) if Player == game.Players.LocalPlayer.Name then Camera.CameraType = Enum.CameraType.Scriptable Camera.CFrame = Camera1.CFrame end end)
I found the answer: Just put the script in StarterPlayerScript, and use FireClient(Player). Don't bother with the verification that the player is the player, since only he is activated. Here is the new script:
Server Script :
--The script is into "ServerScriptService" local Seat = game.Workspace.World.SGC.SeatDHD.Seat local RemoteEvent = game.ReplicatedStorage.SeatDhd Seat.Changed:Connect(function() if Seat.Occupant ~= nil then local Player = game.Players:GetPlayerFromCharacter(Seat.Occupant.Parent) RemoteEvent:FireClient(Player) end end)
Local Script :
--The script is into "StarterPlayerScript" local Seat = script.Parent local RemoteEvent = game.ReplicatedStorage.SeatDhd local Camera = workspace.CurrentCamera local Camera1 = workspace.CameraSeat RemoteEvent.OnClientEvent:Connect(function() Camera.CameraType = Enum.CameraType.Scriptable Camera.CFrame = Camera1.CFrame end)