How do I position my flashlight correctly?

Hello! Thank you for visiting this forum.

I’ll get straight to the point. I was working on a flashlight system that, when the player presses ‘F’, a flashlight model is placed on the UpperTorso.

My issue is that it doesn’t position correctly, as shown in the following image:

This is how I would like my flashlight to appear:

I’ve noticed that this problem can be solved by manipulating Vector3 or CFrame, but my attempts to implement this have failed. I would appreciate it if you could provide a line of code in the following script (located in StarterCharacterScripts) that correctly positions the flashlight as I’ve explained in the previous image. You don’t need to position the flashlight yourselves; I just want to know how to change its position. I might also need to adjust its rotation. My main challenge is that the flashlight is divided into different parts as a model, and I want to adjust the position of the entire model. Thank you for your assistance! :smiling_face:

This is the script:

script.VisualizeFlashlight.OnServerEvent:Connect(function()
	game.Lighting.Flash:Clone().Parent = script.Parent
	script.Parent:WaitForChild("Flash").Handle.Sound:Play()
	local weld = game.Lighting.Weld:Clone()
	weld.Parent = script.Parent
	weld.Part0 = script.Parent.UpperTorso
	weld.Part1 = script.Parent:WaitForChild("Flash").Handle
	-- I want here the code line i think.
end)

This is the FlashLightModel (Inside Lighting):
image

2 Likes

Mess around a little with weld.C0 and weld.C1 until you get the right position,

or just create a dummy, a flashlight and weld and change the C0 and C1 of that weld so you can copy and paste the C0 and C1 later.

If this confused you just stick with this

1 Like

Could you give me an example???

script.VisualizeFlashlight.OnServerEvent:Connect(function()
	game.Lighting.Flash:Clone().Parent = script.Parent
	script.Parent:WaitForChild("Flash").Handle.Sound:Play()
	local weld = game.Lighting.Weld:Clone()
	weld.Parent = script.Parent
	weld.Part0 = script.Parent.UpperTorso
	weld.Part1 = script.Parent:WaitForChild("Flash").Handle
	weld.C1 = CFrame.new(-0.5, 0.5, -0.55)
end)

If it appears on the back try removing the minuses

2 Likes

Thank you! Now i can make my flashlight :smiling_face:!

How i can rotate??? i want to rotate the model

You can just multiply the CFrame with CFrame.Angles()

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.