Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Any Cframing help?

I love weather, so I am making a weather script for my personal place. I built some "clouds" and trying to script them to fly over head. I have no clue what to do with Cframe. (I build with Cframe Tools) But I don't know how to script with it. What I got so far is:

wait (5)
Workspace.Cloud1.part.CFrame = CFrame.new(0, 50, 0)
wait (5)
Workspace.Cloud1.part.CFrame = CFrame.new(0, 50, 0)
wait (5)
Workspace.Cloud1.part.CFrame = CFrame.new(0, 50, 0)

Now. I know I have to change new based on my current location. But I do no know how to do that. Also when I move it. It loses its tilt. Any way to keep that?

(Any and all help will be greatly heeded, Please don't try me to copy a script. I am here to learn lua not copy and paste.)

2 answers

Best way to do this is by inserting a new instance of BodyVelocity into the parts. Basically, it will move the part much like a cloud if you will. Remember that Vector3 represents location, while CFrame represents rotation values. Here is a quick code, though it's not tested.

cloud = script.Parent
move = Instance.new("BodyVelocity")
move.Parent = cloud

while cloud do
cloud.BodyVelocity.velocity = Vector3.new(2, 0, 0) 
wait(2)
cloud.BodyVelocity.velocity = Vector3.new(2, 0, 0)
end

I'm also new to Lua, so if there's any problems, please reply and I'll be happy to help.

~Kyo-chan

3 comments

0

Tested the code, and there are some problems with it. Though it will move just like a cloud would. I will fix it if you wish.

0

Hm, I see if I can fix them myself! :D Thanks a lot. If I can't get it I'll just PM you on Roblox. :p

0

All right, glad I could help in some way! :)

wait (5)
Workspace.Cloud1.part.position = poisition.new(0, 50, 0)
wait (5)
Workspace.Cloud1.part.position = position.new(0, 50, 0)
wait (5)
Workspace.Cloud1.part.position = position.new(0, 50, 0)

Position and rotation also help really well.

This discussion is preserved as it was. New answers, comments, and votes are closed.