local tweenInfo = TweenInfo.new(1)
local tweenOpen = TweenService:Create(hinge, tweenInfo, goalOpen)
local tweenClose = TweenService:Create(hinge, tweenInfo, goalClose)
prompt.Triggered:Connect(function()
if prompt.ActionText == “Close” then
tweenClose:Play()
prompt.ActionText = “Open”
else
tweenOpen:Play()
prompt.ActionText = “Close”
end
end)
“Goalopen” and “goalclose” both apparently have cframe properties, but they are tables? I see this quite alot, I just don’t really get how tables are used for this?
Although they are CFrame properties, when using the TweenService to animate them, the third parameter takes a table of values to change. In this case, that table is simply held by the variables goalOpen and goalClose.
Also, when putting code in a post, please make sure it is in the code format. You can do this by putting three of the ` key either side, or clicking the ‘</>’ button when making the post.
It just makes it easier to understand when reading through it, because it has the proper indentation, keywork colours, etc.
Whenever the variable is mentioned, it just treats it as that same table again. Using a variable just makes it easier and more efficient to code it. For instance:
local variable = {"Test1", "Test2"}
--just storing the table in the variable
--so saying
if table.find(variable, "Test1") then
print("Test1 is in the table!")
end
--is the same as saying
if table.find({"Test1", "Test2"}, "Test1") then
print("Test1 is in the table!")
end
remember, a variable is essentially a pointer to another item.