Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I cframe a player in position when they touch a part?

Hey, I was wondering how I'd make it so once a player touches a part the player moves ina position using c frame (e.g. facing forward), how would I do this? :)

1 comment

0

You would need to change the player's HumanoidRootPart's CFrame based on its CFrame.LookVector

1 answer

CFrame can be used to rotate as well as move an object. You can try something like this:

local Part = workspace.Part
local Players = game:GetService('Players')


Part.Touched:Connect(function(otherPart)
	local Player = Players:GetPlayerFromCharacter(otherPart.Parent) -- use service to get player
	if Player then -- check if player
		local Character = Player.Character or Player.CharacterAdded:Wait() -- get character
		Character.HumanoidRootPart = CFrame = Character.HumanoidRootPart.CFrame * CFrame.Angles(math.rad(0), math.rad(0), math.rad(0))
	end
end)

Use the math.rad() to rotate the player accordingly, while still keeping the Player's position.

This discussion is preserved as it was. New answers, comments, and votes are closed.