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

How do I make this variable work in a while true do loop?

Asked by 7 years ago

So, in one of my while true do loops, I have this code:

seatcframe = game.Players.LocalPlayer.Character.Humanoid.SeatPart.CFrame
seatcframe = seatcframe * CFrame.new(0,1,0)

but... it doesn't work. Although,

game.Players.LocalPlayer.Character.Humanoid.SeatPart.CFrame = game.Players.LocalPlayer.Character.Humanoid.SeatPart.CFrame * CFrame.new(0,1,0)

this ^^ does work, which is annoying since it is crazy long and shouldn't be. This is so frustrating since it is obviously a stupid mistake. Thank you to anyone who can help me.

1 answer

Log in to vote
1
Answered by 7 years ago

I tried something similar to this, but it does not work at all as well. The only fastest way to do this is to index the property in the line where you want to configure it while letting the variable represent the object you want to configure. Here, let me show you!

local seat = game.Players.LocalPlayer.Character.Humanoid.SeatPart -- Local variables are always better than global ones, at least for me. This is the line where I changed what the variables represents.
seat.CFrame = seat.CFrame * CFrame.new(0,1,0) -- Reference the CFrame manually here.

Any questions? Leave them in the comments below. Thanks!

0
Thanks, helped. Your_Momdotcom 91 — 7y
Ad

Answer this question