im trying to make a part follow the mouse when the player sits on the vehicle seat, however it just wont detect anything , the script is cloned and enabled inside the vehicle seat.
local WASD = {
0,
0,
0,
0
}
local function updatePosition()
end
local this = script.Parent.Parent
while wait() do
local PlaneSeat = this:FindFirstChildOfClass("VehicleSeat")
if PlaneSeat.Occupant ~= nil and game:GetService("Players"):GetPlayerFromCharacter(PlaneSeat.Occupant.Parent) then
local mouse = game:GetService("Players"):GetPlayerFromCharacter(PlaneSeat.Occupant.Parent):GetMouse()
if mouse then
this.Body.CFrame = CFrame.lookAt(this.Body.Position,mouse.Hit.Position)
end
end
end
local WASD = {
0,
0,
0,
0
}
local function UpdatePosition()
end
local this = script.Parent.Parent
while task.wait() do
local PlaneSeat = this:FindFirstChildOfClass("VehicleSeat")
if PlaneSeat.Occupant ~= nil and game:GetService("Players"):GetPlayerFromCharacter(PlaneSeat.Occupant.Parent) then
local mouse = game.Players.LocalPlayer:GetMouse()
if mouse then
this.Body.CFrame = CFrame.lookAt(this.Body.Position, mouse.Hit.Position)
end
end
end