Night viewer does not appear on the head

why the night viewer does not appear on the head? How do I do that configuration?
I need to make the night vision object be on the player’s head

image

image

localscript

local tool = script.Parent
local equipped = false
local UID = game:GetService("UserInputService")

tool.Equipped:Connect(function()
	equipped = true
end)

tool.Unequipped:Connect(function()
	equipped = false
end)

local isActivated = false

UID.InputBegan:Connect(function(key,isTyping)
	if equipped == true then
		print("tool equipped")
		if key.KeyCode == Enum.KeyCode.N then
			isActivated = not isActivated
			if (isActivated) then
				pcall(function()
					local StarterGui = game:GetService("StarterGui")
					StarterGui:SetCore("TopbarEnabled", false)
				end)

				local frame = game:GetService("Players").LocalPlayer.PlayerGui
				print("Activated.")
				-- Config 1
				wait(.1)
				frame.Screen:FindFirstChild("NightConfig").BackgroundTransparency = 0.1
				wait(.1)
				frame.Screen:FindFirstChild("NightConfig").BackgroundTransparency = 0.15
				-- Config 2
				wait(.1)
				frame.Screen:FindFirstChild("NightConfig").BackgroundTransparency = 0.25
				wait(.1)
				frame.Screen:FindFirstChild("NightConfig").BackgroundTransparency = 0.4
				wait(.1)
				frame.Screen:FindFirstChild("NightConfig").BackgroundTransparency = 0.6	
			else	
				pcall(function()
					local StarterGui = game:GetService("StarterGui")
					StarterGui:SetCore("TopbarEnabled", true)
				end)
				local frame = game:GetService("Players").LocalPlayer.PlayerGui
				frame.Screen:FindFirstChild("NightConfig").BackgroundTransparency = 1
				print("no activated.")
			end
		end
	end
end)

Can you show a script if you have one?

Sure!

image

localscript

local tool = script.Parent
local equipped = false
local UID = game:GetService("UserInputService")

tool.Equipped:Connect(function()
	equipped = true
end)

tool.Unequipped:Connect(function()
	equipped = false
end)

local isActivated = false

UID.InputBegan:Connect(function(key,isTyping)
	if equipped == true then
		print("tool equipped")
		if key.KeyCode == Enum.KeyCode.N then
			isActivated = not isActivated
			if (isActivated) then
				pcall(function()
					local StarterGui = game:GetService("StarterGui")
					StarterGui:SetCore("TopbarEnabled", false)
				end)

				local frame = game:GetService("Players").LocalPlayer.PlayerGui
				print("Activated.")
				-- Config 1
				wait(.1)
				frame.Screen:FindFirstChild("NightConfig").BackgroundTransparency = 0.1
				wait(.1)
				frame.Screen:FindFirstChild("NightConfig").BackgroundTransparency = 0.15
				-- Config 2
				wait(.1)
				frame.Screen:FindFirstChild("NightConfig").BackgroundTransparency = 0.25
				wait(.1)
				frame.Screen:FindFirstChild("NightConfig").BackgroundTransparency = 0.4
				wait(.1)
				frame.Screen:FindFirstChild("NightConfig").BackgroundTransparency = 0.6	
			else	
				pcall(function()
					local StarterGui = game:GetService("StarterGui")
					StarterGui:SetCore("TopbarEnabled", true)
				end)
				local frame = game:GetService("Players").LocalPlayer.PlayerGui
				frame.Screen:FindFirstChild("NightConfig").BackgroundTransparency = 1
				print("no activated.")
			end
		end
	end
end)

Do you have any errors???

No error, the script works perfectly

Wait, so you are wanting the NVG’s to go on the players head?

1 Like

yes, i need to make the night vision object be on the player’s head

You should set the NVG’s CFrame to the same as the players head.

Do not anchor it and set cancollide to true.

like this?

No, you do it in a script like this:

NVG.CFrame = character.Head.CFrame

How can I create the local character?

tool = script.Parent.Handle
tool.CFrame = character.Head.CFrame

Something like this or am i wrong? :frowning:

local tool = script.Parent
local equipped = false
local UID = game:GetService("UserInputService")

tool.Equipped:Connect(function()
	equipped = true
end)

tool.Unequipped:Connect(function()
	equipped = false
end)

local isActivated = false

UID.InputBegan:Connect(function(key,isTyping)
	if equipped == true then
		print("tool equipped")
		if key.KeyCode == Enum.KeyCode.N then
			isActivated = not isActivated
			if (isActivated) then
				pcall(function()
					local StarterGui = game:GetService("StarterGui")
					StarterGui:SetCore("TopbarEnabled", false)
					
					local player = game.Players.LocalPlayer
					local char = player.Character
					local tool = script.Parent.Handle
					tool.CFrame = char.Head.CFrame
				end)

				local frame = game:GetService("Players").LocalPlayer.PlayerGui
				print("Activated.")
				-- Config 1
				wait(.1)
				frame.Screen:FindFirstChild("NightConfig").BackgroundTransparency = 0.1
				wait(.1)
				frame.Screen:FindFirstChild("NightConfig").BackgroundTransparency = 0.15
				-- Config 2
				wait(.1)
				frame.Screen:FindFirstChild("NightConfig").BackgroundTransparency = 0.25
				wait(.1)
				frame.Screen:FindFirstChild("NightConfig").BackgroundTransparency = 0.4
				wait(.1)
				frame.Screen:FindFirstChild("NightConfig").BackgroundTransparency = 0.6	
			else	
				pcall(function()
					local StarterGui = game:GetService("StarterGui")
					StarterGui:SetCore("TopbarEnabled", true)
				end)
				local frame = game:GetService("Players").LocalPlayer.PlayerGui
				frame.Screen:FindFirstChild("NightConfig").BackgroundTransparency = 1
				print("no activated.")
			end
		end
	end
end)

You would likely to use WeldConstraint so for this you will need make an WeldConstraint in the NightVision and set the Part0 = NightVision, In script we will set CFrame and WeldConstraint.Part1

local NightVision = game.ReplicatedStorage.NightVision:Clone()

NightVision.Parent = Player.Character

Player.Character.NightVision.CFrame = Player.Character.Head.CFrame
Player.Character.NightVision.WeldConstraint.Part1 =  Player.Character.Head

You need to weld it to the head

how could i do that? :scream: :scream:

Its like putting a hat on, you would use the same script as if you were putting on a hat

You could also use the tool holder editor plug in to move the handle to put it on the head