How do I improve/fix my flashlight?

Looking for advice but also help with achieving what I’d like to achieve :slight_smile:

For one, the light bounces as the player walks which is annoying. Also, I’d like the light to move with the player’s camera in 1st person, so if they look up, the light moves up as well.

Video:

Workspace Screenshot Overview

3 Likes

Hey, mabye you could still have the flashlight in the players hand but instead, remove the the light from the flashliht and instead have a part relative to where the camera is rotating that will give the illusion that its emitting from the flashlight and will help with the stabilization of the light

1 Like

I appreciate the feedback! I’m a bit of a noob so I’m not really sure about how to go about that; however, I’ll look into that :slight_smile:

1 Like

Honestly its not as hard as it sounds just place a part say 5 studs in front of the cameras lookvector and then just udpaate the cframe to match the cameras cframe, so itll be 5 studs in front at all times but it will also have the rotation of the camera which will allow you to look up and also see the light


2 Likes

going from what astraIboy said

local flashlightPart = Instance.new("Part")
flashlightPart.Parent = WhereYouWantItToBe
flashlightPart.Position = (game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.LookVector * 3.5) + Vector3.new(5,0,0)
-- Run the setting cframe property in a loop for it to constantly be in that position

i hope this helps slightly, that’s the math done for you anyways lol

2 Likes

Oh my goodness! You’ve explained it so well — even included an illustration!

I’m quite a newbie scripter and camera stuff is a little confusing (I’m getting the hang of tweens though!) so I apologize if I ask silly questions!

Would I be doing all of this via a LocalScript in the StarterPlayerScripts? That is, placing the part & updating the CFrame?

The flashlight itself has a part in it that shines the light (which is probably the issue) and changes its color/material when on.

If I were to make the walking animation of the player less shaky… would that help with the issue as well?

I appreciate the help (I hate math lol)! Would this be a LocalScript in StarterPlayerScripts?

Update: NVM StarterCharacterScripts instead! Would it be a for, while, or repeat loop?

Actually put it into a localscript that would be in StarterCharacterScripts so itll work if the player dies,
Yes an animation that is less shaky could yield the results your looking for + my suggestion above!

1 Like

It would in a heartbeat loop (aka technically a while loop), it updates every frame, meaning the part will be at the cameras cframe 5 studs in front every single frame
image

1 Like

Also dont use @Qoucx code, theres an error in it because hes not actually setting the Cframe to a cframe hes setting it to a Vector3

1 Like

just realised, just edited, thankyou for pointing it out lol

Try this code instead, it should work has intended

So we make the part outside of the loop and then we update its cframe inside of the loop
(we dont want to keep creating parts)

Voila!



2 Likes

Woah! Thank you thank you! Although, how did you insert the spotlight into the part?

You can just create a new spotlight like so


1 Like

Thank you so much! I appreciate it greatly! <3

1 Like

It’s very easy so that the flashlight doesn’t move so the monkey doesn’t move either if you don’t know how then when it is equipped make an animation that doesn’t move the hand

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