Lookvector don't work Or I using it bad?

Hello, I just want set part to be like a humanoidrootpart
But I using lookvector but it don’t do anything here is script I’m doing

while wait(0.00001) do
	script.Parent.Setting.Position = script.Parent.Idk.WorldPosition
	script.Parent.Setting.Orientation = script.Parent.Parent.HumanoidRootPart.CFrame.lookVector
end

Here is results I get
Screenshot_2
Thank for reading
Pixeluted

2 Likes

Hi,

Could you please explain the context of what you’re trying to create? I think people would find it easier to solve your problem if they understood what you’re trying to do a little better. Also a helpful tip for the future would be to make your images a lot more clear, I’m not the most intelligent person by all means but the diagram is quite confusing.

Thanks,
-Tom :slight_smile:

1 Like

Hello, I just want create the invisible part is looking same as humanoidRootpart

Like this
Screenshot_3
Not like this
Screenshot_4

You can simply resize it or add increase the y rotation by 90 to have your desired effect.

No I doing it in script no in studio

Hi,

You should consider using the CFrame mechanic “ToWorldSpace” along with an offset CFrame. ToWorldSpace is a method which moves the object to a position in the world relative to another part (in this case the player’s character) and applies and offset to move it in front.

You should read the “Relative Position” aspect of this article: CFrames | Documentation - Roblox Creator Hub

Hope this helps,
-Tom :slight_smile:

Quick tip: wait() has a minimum value of 0.03, going below that is pointless. use game:GetService("RunService").RenderStepped/Heartbeat instead, renderstepped is fired each frame and heartbeat goes at 60 runs per second

This method would yield the part being positioned exactly into the player’s character and not in front as intended.

RenderStepped and Heartbeat have variable frequencies depending on the client’s performance. If your game is running very slowly and at say, 15 fps, both events would fire 15 times per second and not necessarily 60fps.

The only difference is that RenderStepped runs immediately when the frame is stepped, before any of Roblox’s physics simulations. Heartbeat is the same, however it waits for Roblox’s physics simulations to be completed before running any code associated to it.

For more information see the following articles:

1 Like

I got another problem for my testing part it work but for my main part don’t


Script:

game.ReplicatedStorage.Lighting.OnServerEvent:Connect(function(player)
	local Character = player.Character
	local Lighting = game.ServerStorage.Lighting:Clone()
    Lighting.Parent = workspace
    Lighting.CFrame = Character.Head.CFrame:ToWorldSpace(CFrame.new(0,0,-1))
    Lighting.Anchored = false
    Lighting.Orientation = Character.HumanoidRootPart.CFrame.lookVector.Unit
    while wait(0.1) do
	Lighting.Anchored = true
	local Tween1 = game:GetService("TweenService"):Create(Lighting,TweenInfo.new(0.2,Enum.EasingStyle.Sine,Enum.EasingDirection.In),{Size = Lighting.Size + Vector3.new(3,0,0)})
	 Lighting.CFrame = Character.Head.CFrame:ToWorldSpace(CFrame.new(0,0,-1))
	Tween1:Play()
   end
end)

Hi,

What exactly is your expected outcome? Is it that the blue part is too long? I’m not sure what would qualify as success at the moment. Have you tried manipulating the dimensions of the part in question to make it fit more with your plans?

Thanks,
-Tom :slight_smile:

My main point is that he seemed to be trying to get a “weld” like effect, at least visually. renderstepped does that. I’m aware that renderstepped runs slower, but i didn’t know heartbeat was also bound to physics. but hey, the more you know :sunglasses:

Hello, It’s just not correct position so I want do magic beam from your head and when is touch somebody player it kill him , In total I got 2 problem 1.Position is not correct 2. I need longer it only on one side

Hi,

Have you considered using Raycasts? Raycasts are essentially a beam that is infinite in one direction but finite in the other, you could use a Ray to create the lightning bolt itself and you could add a Touch event to any parts associated along the Ray to check whether the beam is actually hitting anyone.

Alternatively you could use the Target property of the Player’s Mouse to determine whether the player has hit a Humanoid model. This becomes automatic and could potentially lead to issues such as players shooting through walls however seems like it would be functional for what you’re trying to achieve.

Raycasting is something that can be quite complex and needs a lot of patience and getting used to, this guide will get you up to speed on it pretty quicker (just imagine the player’s head is the gun in this instance): Documentation - Roblox Creator Hub

For references about Raycasting in the Roblox engine, read this article:

For references about the Mouse method, read this article:

Hope this helps,
-Tom :slight_smile:

1 Like

Sorry, But I never can’t figure out how to use Ray any of these references
I just can’t do that

Scripting is all about perseverance, it’s not impossible to learn how to Raycast and it will give you an edge on your games if you can successfully figure it out. Have a look at how successful Raycasts are done in the examples I’ve sent above, and if you get errors just research what could have caused the errors. There are plenty of guides, tutorials and people out there willing to lend a hand.

I should watch some youtube videos about Ray