Hello! I’m struggling with making a system, that equips Halo (animated with TweenService) on the player’s head.
-
What do you want to achieve?
I want Halo to be cloned to the character’s head with Tween animation. -
What is the issue?
My script works perfectly fine, however there is a strange thing with Halo’s position when its being cloned to the character’s head, it makes a feeling that it’s like being “Anchored” to the position.
- Before moving.
- What solutions have you tried so far?
It works perfectly with Weld and WeldConstraint if Halo is static (without Tween), but I want it to be animated.
I tried searching on YT and tried to make a Handle for it, but It didn’t work.
Here is a snippet of my code, which is being used:
(To clone it to the character’s head)
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local eventFolder = game.ReplicatedStorage.Events
local halo = ReplicatedStorage.Halo
eventFolder.EquipHalo.OnServerEvent:Connect(function(plr)
local head = plr.Character:FindFirstChild("Head")
-----------------------------------------------------------
local cloneHalo = ReplicatedStorage.Halo:Clone()
cloneHalo.Parent = head
cloneHalo:PivotTo(head.CFrame)
local weldHalo = Instance.new("WeldConstraint")
weldHalo.Parent = cloneHalo
weldHalo.Part0 = cloneHalo
weldHalo.Part1 = head
print("Weld Done!")
cloneHalo.Position = head.Position + Vector3.new(0, 0.7, 0)
end)
Here is a code which is a child of Halo
(Animation)
local TweenService = game:GetService("TweenService")
local halo = script.Parent
local rotation = {}
rotation.Orientation = halo.Orientation + Vector3.new(0, 360, 0)
local tweenInfo = TweenInfo.new(
8,
Enum.EasingStyle.Linear,
Enum.EasingDirection.InOut,
-1,
false,
0
)
local tween = TweenService:Create(halo,tweenInfo,rotation):Play()
---------- Tween 2 (Up and Down) ----------
local upAndDw = {}
upAndDw.Position = halo.Position + Vector3.new(0, 0.2, 0)
local tweenInfo2 = TweenInfo.new(
4,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
-1,
true,
0
)
local tweenUaD = TweenService:Create(halo,tweenInfo2, upAndDw):Play()
P.S I’m new to DevForum, so If I made a mistake in formatting my text, let me know!
Also, if my code is messy or if it’s possible optimize it, I would be happy to hear that!
Thank you!