I have a flashlight, which i want to lock to the players orientation, but the flashlight only points to the bottom.
Here is my code:
local tool = script.Parent.Parent
local equipped = false
tool.Equipped:Connect(function()
equipped = true
local char = tool.Parent
while equipped and wait() do
tool.Grip = CFrame.new(Vector3.new(0,0,0), char.Head.Orientation)
end
end)
tool.Unequipped:Connect(function()
equipped = false
end)
I might have misunderstood, but if you’re trying to change the direction of where the tool is pointing, why not just manually rotate the handle/grip in studio?
I want to rotate the Flashlight to the exact location the player is looking at.
So if the player looks up, the flashlight will follow the players orientation and when he looks back down, the flashlight will also look back down.
I hope you understand
Ah great, that’s called a ViewModel. It’s gonna be a bit messy if I have to explain it all over one reply, so I’ll link a video which explains how to set it all up. Best of luck! How to make a ViewModel From Scratch - YouTube.
You’re welcome to reply with further questions if something isn’t working as you intend.
Thank you! That worked, but whenever im in first person now, i automatically move forward. Do you have an idea why this is the case or even have an solution to this?
One last thing, no need to reply, but I forgot to mention which the video doesn’t show, you wanna add this code to the local script. And you wanna replace the “:SetPrimaryPartCFrame” with “:PivotTo”.
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.Died:Connect(function()
ViewModel.Parent = nil
end)
This deletes the viewmodel every time the player dies, and a new one is automatically created when player respawns.