Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there anyway to do what I'm trying to do using the method I've used?

Asked by 4 years ago

Recently I've been trying to make my Player tilt Corresponding to the Platform they are standing like what they do in an Unpopular Game Called Boost Vector and in Sonic Simulator. The method I used is:

-- Variables/Instances
local Player = script.Parent.Parent
repeat wait() until Player.Character.HumanoidRootPart
local Humrp = Player.Character.HumanoidRootPart

local Hitbox = Instance.new("Part",Humrp)
Hitbox.CFrame = Humrp.CFrame
Hitbox.CanCollide = false
Hitbox.Transparency = 1
Hitbox.Size = Vector3.new(3,6.2,3)

local Weld = Instance.new("WeldConstraint",Humrp)
Weld.Part0 = Humrp
Weld.Part1 = Hitbox

local Hit
local CanTurn = false

-- Functions
Hitbox.Touched:Connect(function(hit)
    if hit.Name == "FloorPart" then
        if Hit == hit then return end
        CanTurn = true
        Hit = hit
    end
end)

Hitbox.TouchEnded:Connect(function(hit)
    if hit.Name == "FloorPart" and hit == Hit then
        Hit = nil
        CanTurn = false
    end
end)

while true do
    wait(0.005) -- Added a wait() to avoid lagging
    if CanTurn == true then
        Humrp.CFrame = Humrp.CFrame*CFrame.Angles(math.rad(Hit.Orientation.X),0,math.rad(Hit.Orientation.Z))
    end
end

Answer this question