Hey guys!
So look…
I am kind of new to the physics aspect of Roblox Studio, as I never really ever learned anything about it, so I am definitely going to need some help here, if possible
What I am trying to do is make a slope tilting system. The slope tilting system is very basic, you go on a slope, it tilts the character in the direction that the slope is going to. Well, it does that just fine, but its a few problems…
- The player gets flinged off of the slope the higher they go
- Player clips through the slope, like the character is walking inside of it
- Lastly, I just don’t know how to fix this issue…
Here is the script to the the slope tilting system:
local plr = game:GetService('Players').LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid") --head
local rootPart = char:WaitForChild("HumanoidRootPart") --head
local detector = char:WaitForChild("detector") --part i welded to head
local xzGyro = Instance.new("BodyGyro")
xzGyro.MaxTorque = Vector3.new(3e5,0,3e5)
xzGyro.P = 5e5
xzGyro.Parent = rootPart
tweenservice = game:GetService("TweenService")
game:GetService("RunService").RenderStepped:Connect(function()
local params = RaycastParams.new()
params.FilterDescendantsInstances = {char}
params.FilterType = Enum.RaycastFilterType.Exclude
local result = workspace:Raycast(detector.Position, Vector3.new(0,-10,0), params)
if (result) and humanoid.FloorMaterial ~= Enum.Material.Air then
local currentRightVector = detector.CFrame.RightVector
local upVector = result.Normal
local newFacialVector = currentRightVector:Cross(upVector)
local tween = tweenservice:Create(xzGyro, TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.In), {CFrame = CFrame.fromMatrix(detector.Position, currentRightVector, upVector, newFacialVector)})
tween:Play()
humanoid.HipHeight = 0.5
else
wait()
xzGyro.CFrame = xzGyro.CFrame:Lerp(CFrame.new(detector.Position, detector.Position + detector.CFrame.RightVector, detector.Position + Vector3.new(0,1,0)), 0.05)
end
end)
If your experienced, this code might be super basic to you ![]()
I would like to get guidance on how I could achieve the things that are listed above. Any help is appreciated. ( If you need me to make myself clearer, please let me know! )
( btw if ur confused with what this game is supposed to be, its just supposed to be a platformer based game, not no random cheap sonic engine or anything like that
)