You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want to add an aura to my player and when they run around I want it to follow.
- What is the issue? Include enough details if possible!
Right now, the aura loads in perfectly, but once I take off running the aura stays behind.
- What solutions have you thought of so far?
I tried using a WeldConstraint. This made the aura stick to the player like glue but as the aura rotated around it forced the player to rotate as well.
I tried changing my rotation script to follow the player. This made the aura follow the player but there was such a delay/lag with it the aura was always about 10 feet behind me until I stopped moving so it could catch up.
I played with CFrame’s and anchored properties. I think I’m probably just going about this wrong.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Here’s what I’m doing. When the player equips an aura (button click) I take the parts that contain it and I weld them onto the player character. I have 13 auras in my game so far and this works for all but this one. This is my only aura using parts though, instead of just particle effects so I think that is the difference that is throwing me off.
Here is my weld-to-player code:
local function weldParts(source, target)
for _, part in ipairs(source:GetChildren()) do
if part:IsA("BasePart") then
local correspondingPart = target:FindFirstChild(part.Name)
if correspondingPart then
local partClone = part:Clone()
partClone.Parent = correspondingPart
partClone.CFrame = correspondingPart.CFrame
local weld = Instance.new("WeldConstraint")
weld.Part0 = correspondingPart
weld.Part1 = partClone
weld.Parent = correspondingPart
end
elseif part:IsA("Model") then
local correspondingPart = target:FindFirstChild(part.Name)
if correspondingPart then
weldParts(part, correspondingPart)
end
end
end
end
And this is my script to rotate the parts and move them up and down around the player (this script hangs off the moving part itself).
local water = script.Parent
local direction = "up"
local height = 5
local low = 3
local player = nil
local function GetPlayer()
local player = game:GetService("Players"):GetPlayerFromCharacter(water.Parent.Parent.Parent)
return player
end
while true do
local waistPoint
if player == nil then
player = GetPlayer()
waistPoint = player.Character:WaitForChild("LowerTorso").Position.Y
water.CFrame = player.Character:WaitForChild("LowerTorso").CFrame - Vector3.new(0, 3, 0)
else
waistPoint = player.Character:WaitForChild("LowerTorso").Position.Y
if direction == "up" then
water.CFrame = player.Character:WaitForChild("LowerTorso").CFrame * CFrame.Angles(0, math.rad(5), 0) + Vector3.new(0, 0.1, 0)
else
water.CFrame = player.Character:WaitForChild("LowerTorso").CFrame * CFrame.Angles(0, math.rad(5), 0) - Vector3.new(0, 0.1, 0)
end
if water.Position.Y > waistPoint + height then
direction = "down"
end
if water.Position.Y < waistPoint - low then
direction = "up"
end
end
task.wait(0.02)
end
Excuse the hackiness, I get it working then clean up the code Thanks for looking.