Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Part.CFrame.X not actually where the part's X is?

Asked by 5 years ago
Edited 5 years ago

I think my issue has something to do with how I set up the CFrames, since I'm a little new to CFraming things, but I have a script that's supposed to teleport a bunch of lightning particles around a ball. The lightning particles teleport around, but instead of teleporting around the ball, they teleport around a certain spot near the ball, but if I move the ball, they stay in the same place.

Here's what I mean: https://gyazo.com/bfec77534ec60a28553e0aff2ab31902

This is in a server script, and all of the lightning particles are inside of the part, and so is the script.

Script:

local part = script.Parent

local l1 = part:WaitForChild("1")
local l2 = part:WaitForChild("2")
local l3 = part:WaitForChild("3")
local l4 = part:WaitForChild("4")
local l5 = part:WaitForChild("5")

while wait(0.01) do

    l1.Transparency = 1
    l2.Transparency = 1
    l3.Transparency = 1
    l4.Transparency = 1
    l5.Transparency = 1

    l1.CFrame = CFrame.new(part.CFrame.X + math.random(0,4), part.CFrame.Y + math.random(0,4), part.CFrame.Z + math.random(0,4)) * CFrame.Angles(math.random(0,360),math.random(0,360),math.random(0,360))
    l2.CFrame = CFrame.new(part.CFrame.X + math.random(0,4), part.CFrame.Y + math.random(0,4), part.CFrame.Z + math.random(0,4)) * CFrame.Angles(math.random(0,360),math.random(0,360),math.random(0,360))
    l3.CFrame = CFrame.new(part.CFrame.X + math.random(0,4), part.CFrame.Y + math.random(0,4), part.CFrame.Z + math.random(0,4)) * CFrame.Angles(math.random(0,360),math.random(0,360),math.random(0,360))
    l4.CFrame = CFrame.new(part.CFrame.X + math.random(0,4), part.CFrame.Y + math.random(0,4), part.CFrame.Z + math.random(0,4)) * CFrame.Angles(math.random(0,360),math.random(0,360),math.random(0,360))
    l5.CFrame = CFrame.new(part.CFrame.X + math.random(0,4), part.CFrame.Y + math.random(0,4), part.CFrame.Z + math.random(0,4)) * CFrame.Angles(math.random(0,360),math.random(0,360),math.random(0,360))

    l1.Transparency = 0
    l2.Transparency = 0
    l3.Transparency = 0
    l4.Transparency = 0
    l5.Transparency = 0

end

If you know what the issue is, I would greatly appreciate if you could explain to me what's wrong with my script.

Edit: I figured out why they weren't originally appearing around the part, but they still don't move when I move the part.

Second Edit: I did some testing, and instead of using CFrames, I used .Position and .Orientation, but it still did the same thing. I've also tried putting the part variable inside of the loop, but that doesn't work either.

Answer this question