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 change the orientation of a part according to the orientation of my character?

So this is the what i want to do : https://prnt.sc/ohvdo7

I want to change the orientation of the part, leaving it straight for my character as it is in the image above

Code:

game.Workspace.Events.Spike.OnServerEvent:Connect(function(player, Mouse)
	
	wait()
	
	local OBJ = game.ReplicatedStorage.oSpike:Clone()
	
	OBJ.Parent = game.Workspace
	
	OBJ.Anchored = true
	
	OBJ.CFrame = player.Character.LeftHand.CFrame * CFrame.new(0,0,0)
	
end)

2 answers

OBJ.CFrame = player.Character.LeftHand.CFrame * CFrame.new(0,0,0) * CFrame.Angles()
game.Workspace.Events.Spike.OnServerEvent:Connect(function(player, Mouse)
local OBJ = game.ReplicatedStorage.oSpike:Clone()
OBJ.Anchored = true
local Head = Player.Character.Head
OBJ.CFrame = CFrame.new((Head.Position)+ Head.CFrame.LookVector * 2, Head.CFrame.LookVector*3)
OBJ.Parent = game.Workspace
end)

What this does is put the spike infront of the player who fired the events head. Then it sets the look vector to to the same as the heads (just multiplied) The look vector is just what direction the part is facing.

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