I have a script in a text button in starter gui that detects if its clicked. Upon click, it gets the already confirmed to exist vehicle seat that the player who clicked is sitting on and sends the car model the seat is in to a server script in this one via a remote event. In the server script, it flips the car, because this is supposed to be a flip car button. Apparently I can print the name of the model and the model itself in the server script, but anything about the model is seemingly nil. Including primary part, which is what I use to orient the car on flip. Is there a way to make a flip button different, or is there a way to prevent it becoming nil?
This is the local script that has the server script parented to it.
Player = game.Players.LocalPlayer
Player.Character.Humanoid:GetPropertyChangedSignal("Sit"):Connect(function()
script.Parent.Visible = not script.Parent.Visible
end)
script.Parent.MouseButton1Click:Connect(function()
local Model = Player.Character.Humanoid.SeatPart.Parent.Parent
script.Flip:FireServer(Model)
game.SoundService.Select:Play()
end)
This is the server script
script.Parent.Flip.OnServerEvent:Connect(function(player: Player, Model)
local AngleZ = -Model.PrimaryPart.Orientation.Z
local AngleX = -Model.PrimaryPart.Orientation.X
Model:PivotTo(Model:GetPivot() * CFrame.Angles(math.rad(AngleX), 0, math.rad(AngleZ)))
Model:PivotTo(Model:GetPivot() + Vector3.new(0,20,0))
end)