Currently, I’m just repeatedly setting the position underneath the player but it doesn’t look smooth. I am looking for alternate ways to move it so its more nice and clean.
Any help is appreciated thanks!
while wait() do
if hrp then
cloud.Position = Vector3.new(hrp.Position.X,cloud.Position.Y,hrp.Position.Z)
end
end
Hi! Yes it does seem to work a lot better
However, the cloud model is using a weld to connect the model together so I was wondering how I would get the other parts to move along with it since I’ve changed it to a localscript (was a server previously)
I’ve changed to WeldConstraints but the welded parts dont seem to be appearing anymore, this is the script I use to weld them together
local PrimaryPart = script.Parent.PrimaryPart
local Parts = script.Parent:GetChildren()
for i = 1,#Parts do
if Parts[i]:IsA("BasePart") then
local weld = Instance.new("WeldConstraint")
weld.Part0 = PrimaryPart
weld.Part1 = Parts[i]
-- weld.C0 = PrimaryPart.CFrame:Inverse()
-- weld.C1 = Parts[i].CFrame:Inverse()
weld.Parent = PrimaryPart
end
end
Im not sure if for some functionality of your cloud it MUST be welded together. However I thought I’d just add if you can get away with it all being Anchored (which they will have to be to use this method), you could consider using :SetPrimaryPartCFrame() to move the cloud.
You’d first have to set the PrimaryPart of the cloud model, preferably one of the central clouds, or maybe a central invisible part. PrimaryPart is a property of a Model. You can set it by selecting the property value box and then clicking on the central part.
Then, in your script, you’d replace cloud.Position = Vector3.new(hrp.Position.X,cloud.Position.Y,hrp.Position.Z)
with cloud:SetPrimaryPartCFrame(CFrame.new(Vector3.new(hrp.Position.X,cloud.Position.Y,hrp.Position.Z)))
The only negative of this method is if there are numerous parts in the model and the game is considered quite heavy to run, you may occasionally find parts of the cloud jolting.
I’d imagine you’d have to reduce the hrp.Position.Y so the cloud sits under the player. Hope this helps, apologies if it doesn’t!
Thanks for the response!
I tried this method but it made my clouds disappear so I decided to just make it a part instead of a model so things would be alot easier.
In my game, I have a circle (halo) that follows around under the character (you can see it in action here, just equip the harvest tool; the circle is easier to see out in the grass). The halo is a model with a few hidden parts. This is how I attach with WeldConstraints to the humanoid root part:
local halo = ServerStorage:WaitForChild("Halo")
game.Players.PlayerAdded:connect(function(player)
local char = player.Character or player.CharacterAdded:wait()
local charHalo = halo:Clone()
charHalo.Parent = char
for idx, part in ipairs(charHalo:GetChildren()) do
if part:IsA("Part") then
local rootPart = char.HumanoidRootPart
-- preserve part orientation
local rotation = CFrame.fromOrientation(part.CFrame:ToOrientation ( ))
part.CFrame = (rootPart.CFrame * rotation) - Vector3.new(0, 2.6, 0)
local weld = Instance.new("WeldConstraint")
weld.Parent = part
weld.Part0 = rootPart
weld.Part1 = part
end
end
end)
note that the 2.6 in Vector3.new(0, 2.6, 0) really should be HipHeight.