Help with tweening an object

So I have a simple code that checks if the player has the night vision goggles then it waits for “N” to be tapped and then it’ll do two things: change the vision of the player so that they can see in the night, and it’ll fire the server, passing two values: a bool and an object, this is my code so you can make sense of what i’m trying to say:

local UIS = game:GetService("UserInputService")
local char = script.Parent
local DA = game.Lighting.OutdoorAmbient
local event = game.ReplicatedStorage:WaitForChild("NVG")
UIS.InputBegan:Connect(function(i,p)
	if p then return end
	if i.KeyCode == Enum.KeyCode.N then
		if char:FindFirstChild("HELMET").MeshPart then--checks if plr has the goggles 
			if game.Lighting.ColorCorrection.Enabled == true then
				game.Lighting.OutdoorAmbient = DA
				game.Lighting.ColorCorrection.Enabled = false
				event:FireServer(false,char:FindFirstChild("HELMET").MeshPart)--fires and passing theses two values, later you'll see why
				
				game.Lighting.OutdoorAmbient = Color3.fromRGB(70,70,70)

			else
				game.Lighting.OutdoorAmbient = Color3.fromRGB(255,255,255)
				game.Lighting.ColorCorrection.Enabled = true
				event:FireServer(true,char:FindFirstChild("HELMET").MeshPart)
			end
			
			

		end

end		
end)

this is the server code:

local event = game.ReplicatedStorage:WaitForChild("NVG")
local TweenService = game:GetService("TweenService")
event.OnServerEvent:Connect(function(plr,val,obj)
	if val == true then--checks if the value we passed is true if it is then it'll tween the NODs
		local Tween = TweenService:Create(obj,TweenInfo.new(),{CFrame = obj.CFrame * CFrame.Angles(0,math.rad(50),0)})
		Tween:Play()
		
	else
		--i was planning to do the "down" tween here but the first tween doesn't even work
		
	end
end)

but nothing happens, it doesn’t move, i do have the Night Vision goggles welded to the helmets main part, which is welded to the players head. but i don’t know if that has anything to do with it:
here is a visual:


so yeah, all the parts of the helmet is welded to one main part, and then that main part is welded to the players head. But if the fact that the Night Vision Goggle is welded to the Main Part is the reason why its not moving then how do I make it to where the Night vision goggles tween up and down everytime the player presses “N” because how can I move it down or up if it has to be welded because if it isn’t, it’ll fall. Do i have to use other methods? if so what methods?

1 Like

should i try animating with an animator plugin? can animations still play even when the object is welded? (not anchored)

1 Like

tbh i would ve done it with an animation, but if you are sending cframes to the server you might aswel just give the client networkownership over the goggles (it probably has that already if you parented it to the char) and then just manipulate it from the client

btw you probably have to tween the welds C0 or C1 whatever you are using for it turn (assuming you are using regular welds)
if you used weldconstaints this wouldnt be a problem

2 Likes

Yes, i was thinking that. all the other methods like tweening the C0 and using constraints didn’t work