I am making a car game and creating the cars completely from startercharacters.
the vehicles move fine but once it reaches a slope of some point, the angle of it does not change.
this is how it looks:
this is the model:
and this is the code i tried:
local RunService = game:GetService(“RunService”)
local Players = game:GetService(“Players”)
local plr = Players.LocalPlayer
repeat wait() until plr.Character or plr.CharacterAdded:Wait()
local char = plr.Character
local HRP = char:WaitForChild(“Torso”)
local Reference = HRP:WaitForChild(“Reference”)
RunService.RenderStepped:Connect(function()
local r = Ray.new(HRP.Position, HRP.CFrame.UpVector * -(char.Humanoid.HipHeight + 3.5))
local ,,n = workspace:FindPartOnRayWithIgnoreList(r,{char})
local h, hp = workspace:FindPartOnRay(r, char) – hit, hitpart
local vector = (HRP.CFrame - HRP.CFrame.p):VectorToObjectSpace(n)
--print(Reference.Transform)
--print(math.abs(vector.z))
if h and string.sub(h:GetFullName(), 1, 16) == "Workspace.Sloped" then
Reference.Transform = CFrame.new(0,0,0,1,0,0,0,1,0,0,0,1) * CFrame.Angles(vector.z,0,-vector.x)
else
Reference.Transform = CFrame.new(0,0,0,1,0,0,0,1,0,0,0,1)
end
end)
the car doeset have any motord6’s of any sort in them does not have any legs, arms, or a humanoidrootpart, so i am unsure how to do this. any ideas?