How to rotate head in a script using TweenService?

local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local SoundService = game:GetService("SoundService")

local Summon_Gaster_Blaster = script.Parent
local Gaster_Blaster = Summon_Gaster_Blaster.Parent:WaitForChild("Gaster Blaster")
local Gaster_Head = Gaster_Blaster:WaitForChild("Head")
local Charge_Up_Position = Gaster_Head:WaitForChild("Charge_Position")

local Charge_Up = Gaster_Blaster:WaitForChild("Charge_Up")
local Fire_Laser_Beam = Gaster_Blaster:WaitForChild("Fire_Laser_Beam")
local Awaken = Gaster_Blaster:WaitForChild("Awaken")

local LocalPlayer = Summon_Gaster_Blaster.Parent.Parent.Parent.Parent
local character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Humanoid = character:WaitForChild("Humanoid")
local HRP = character:WaitForChild("HumanoidRootPart")
local Head = character:WaitForChild("Head")

local Touch_Laser
local Fire_Beam
local MAX_RANGE = 1000

local Summon_Blaster = Summon_Gaster_Blaster.OnServerEvent:Connect(function(player)
	Fire_Beam = coroutine.create(function()
		local Gaster_Blaster_Clone = Gaster_Blaster:Clone()
		Gaster_Blaster_Clone.Parent = game.Workspace
		Gaster_Blaster_Clone:PivotTo(CFrame.new(Head.Position))
		Awaken:Play()
		
		for i, Eye in Gaster_Blaster_Clone.Head:WaitForChild("Eyes"):GetChildren() do
			TweenService:Create(Eye, TweenInfo.new(Awaken.TimeLength, Enum.EasingStyle.Linear), {Transparency = 0}):Play()
		end
		
		TweenService:Create(Gaster_Blaster_Clone.Head, TweenInfo.new(1, Enum.EasingStyle.Linear), {CFrame = CFrame.Angles(math.random(25), 0, 0)}):Play()
		
		local Laser = Instance.new("Part")
		Laser.Anchored = true
		Laser.Position = Charge_Up_Position.WorldCFrame.Position
		Laser.Material = Enum.Material.Neon
		Laser.Color = Color3.fromRGB(255, 255, 255)
		Laser.Size = Vector3.new(0.1, 0.1, 0.1)
		Laser.CanCollide = false
		Laser.CastShadow = false
		Laser.Parent = game.Workspace
		
		Charge_Up:Play()
		
		local Charge_Beam = TweenService:Create(Laser, TweenInfo.new(Charge_Up.TimeLength, Enum.EasingStyle.Linear), {Size = Vector3.new(4, 4, 4)})
		Charge_Beam:Play()
		Charge_Beam.Completed:Wait()
		
		Laser.Size = Vector3.new(4, 4, MAX_RANGE)
	end)
	
	coroutine.resume(Fire_Beam)
end)


I’m trying to tween the head’s rotation on the red line by 25 degrees but I’m not sure how to do it. Here’s the code I have so far though!

Change it to this:

TweenService:Create(Gaster_Blaster_Clone.Head, TweenInfo.new(1, Enum.EasingStyle.Linear), {CFrame = Gaster_Blaster_Clone.Head.CFrame * CFrame.Angles(math.rad(25), 0, 0)}):Play()

You shouldnt randomise the orientation, idk why your doing that, and CFrame.Angles takes in radians, not degrees.

And you also need to get the current orienation to add onto, otherwise it’ll start from 0.

Additionally, add print statements after the tween to see if it plays at all.

Let me know if this works.

Whoops, I accidentally put random instead of rad. I used random a lot so it popped up first lol anyways I’ll try ur code


I mean it almost worked but I’m not sure how to make the other stuff move with it such as the eyes and the fillings.

Youll have to weld them to the main part, you can use WeldConstraints for that.

Thank You, it works! Also one last question I’m trying to make it tween the head after the eyes “glow-up or awaken” but I’m not sure how to do it

local Summon_Blaster = Summon_Gaster_Blaster.OnServerEvent:Connect(function(player)
	Fire_Beam = coroutine.create(function()
		local Gaster_Blaster_Clone = Gaster_Blaster:Clone()
		local Gaster_Blaster_Head_Clone = Gaster_Blaster_Clone.Head
		Gaster_Blaster_Clone.Parent = game.Workspace
		Gaster_Blaster_Clone:PivotTo(CFrame.new(Head.Position))
		Awaken:Play()
		
		for i, Eye in Gaster_Blaster_Head_Clone.Eyes:GetChildren() do
			TweenService:Create(Eye, TweenInfo.new(Awaken.TimeLength, Enum.EasingStyle.Linear), {Transparency = 0}):Play()
		end
		
		TweenService:Create(Gaster_Blaster_Clone.Head, TweenInfo.new(1, Enum.EasingStyle.Linear), {CFrame = Gaster_Blaster_Clone.Head.CFrame * CFrame.Angles(math.rad(25), 0, 0)}):Play()
		
		local Laser = Instance.new("Part")
		Laser.Name = "Gaster_Laser"
		Laser.Anchored = true
		Laser.Position = Charge_Up_Position.WorldCFrame.Position
		Laser.Material = Enum.Material.Neon
		Laser.Color = Color3.fromRGB(255, 255, 255)
		Laser.Size = Vector3.new(0.1, 0.1, 0.1)
		Laser.CanCollide = false
		Laser.CastShadow = false
		Laser.Parent = game.Workspace
		
		Charge_Up:Play()
		
		local Charge_Beam = TweenService:Create(Laser, TweenInfo.new(Charge_Up.TimeLength, Enum.EasingStyle.Linear), {Size = Vector3.new(4, 4, 4)})
		Charge_Beam:Play()
		Charge_Beam.Completed:Wait()
		
		Laser.Size = Vector3.new(4, 4, MAX_RANGE)
	end)
	
	coroutine.resume(Fire_Beam)
end)

Tween the whole head? You can just weld everything, let me know if thats what you want.

Yeah I welded everything! I’m trying to make it tween the head after the eyes are done tweening its transparency though but idk how to do it

You can make a PrimaryPart and weld everything to that, so when you manipulate it, everything moves with it.

If your talking about transparency, just do {Transparency = 1} in the goal part of the tween.

Oh alright, I will do it. Thank You! :smiley:

1 Like

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