I have made beam effects for my sword so it can spin around the sword using one middle part which is welded to all other parts making up the beams.
I’ve made a code that should be spinning the middle part in a 360 motion repeatedly but it doesn’t work.
Code
local Sword = script.Parent.Parent.Parent.Sword
local Handle = Sword:WaitForChild("Handle")
local Equipped = false
local BeamCurlEffect = nil
local function EquippedSword()
Equipped = true
BeamCurlEffect = ReplicatedStorage:FindFirstChild("BeamCurlEffect"):Clone()
BeamCurlEffect.Parent = workspace
while Equipped do
RunService.RenderStepped:Wait()
if BeamCurlEffect:FindFirstChild("Middle") then
BeamCurlEffect.Middle.CFrame = Handle.CFrame
BeamCurlEffect.Middle.CFrame *= CFrame.fromEulerAnglesXYZ(0,0,0.5)
end
end
end
Sword.Equipped:Connect(EquippedSword)
Sword.Unequipped:Connect(function()
Equipped = false
if BeamCurlEffect then
BeamCurlEffect:Destroy()
end
end)
Note: I’ve also tried putting the beams inside the sword but when I rotate the Middle part it just rotates the entire character.
Are there any ways to fix this or any alternatives I can do to accomplish this? any help is appreciated.