So i basically just need the player to face a certain direction whenever he/she is touching a part. Also the player will not be able to move (they are anchored) when on the part. any help or advice?
✓ ANSWER ACCEPTED
force player to face a certain direction when on a part?
1 answer
✓ Accepted answer
local adjustment = 90 -- deegrees the player should turn around adjust it
local adjustmentorientation = CFrame.Angles(0,math.rad(adjustment),0) -- putting it into a CFrame component
local Part = script.Parent -- the touched part, should be over the actual part invisible and cancollide = false!
local deb = false -- debounce
Part.Touched:Connect(function(touched) -- when part gets touched it fires
if deb then return end -- end function when debounce
deb = true -- debounce activated
local hum = touched.Parent:FindFirstChild("Humanoid") -- get rootpart returns nil/the humanoid
local rootpart = touched.Parent:FindFirstChild("HumanoidRootPart") -- get rootpart returns nil/the part
if hum ~= nil then -- check if humanoid is there
if rootpart ~= nil and rootpart.Anchored == false then -- checks if player is already anchored and rootpart not nil
rootpart.CFrame = Part.CFrame*adjustmentorientation -- Tps Player to the Part you have to adjust the Part height
--^^ you can also just add up the height but this is a simpler solution
-- you can add a wait if there are any bugs
rootpart.Anchored = true -- makes player unable to move
-- this prevents the player from running forever after being anchored its a bug:
wait(1) -- wait till player is anchored
for i,track in pairs(hum:GetPlayingAnimationTracks()) do -- get all playing animations
track:Stop() -- stops each track
end
end
end
wait(0.2) -- wait to make it lag less
deb = false -- turns debounce off
end)
--[[ PROBLEMS:
When the part height isn't right then there could be unwanted animations playing.
Also if the animations dont stop, maybe make it a local script and disable the animationscript]]
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
ok i made some small adjustments and it works perfectly. thanks man!
No problem! :)