Hi,
I need some help with a script.
So I want too make it so when you click a text button it will tween a part.
Im not sure how to make it though. I have the tween script and the click function but theres an error in the script.
so as you see here the “=” is underlined and the end of the table. The error the script is saying is
I have no idea what to do and I would appreciate it if some helped me.
1 Like
Sarchyx
(Sarchyx)
July 31, 2021, 8:48pm
#2
When you specify the Instance on TweenService:Create() first parameter it gets the property from there so the Properties table would be:
local Properties = {
Position = Vector3.new(20, 25.5, 0)
}
local Tween = TweenService:Create(script.Parent, TweenInformation, Properties)
Btw it gives you that error because a table is a store of 1 or more values, so you can’t modify an Instance’s property inside them.
1 Like
what do you mean by values? Also I still don’t really understand tables.
Sarchyx
(Sarchyx)
July 31, 2021, 8:54pm
#4
Values are just “things” that you can store with a variable or table, such as strings, numbers and bools
oh. Okay. Also how to I refer to the part that is tweeting? Because I have to refer to the part because nothings referring to it in the script.
Sarchyx
(Sarchyx)
July 31, 2021, 8:57pm
#6
Yes, script.Parent is the parent of the script you are writting, so to refer to the part you would just need to put the script inside of the part.
is it a server or local script?
Sarchyx
(Sarchyx)
July 31, 2021, 9:01pm
#8
A server script would tween the part for everyone in the server, so it’s a server script.
okay. Also it still doesnt work. Since I think im referring to the screen gui too far.
I have to refer to section 1
also it looks like this
Sarchyx
(Sarchyx)
July 31, 2021, 9:05pm
#10
Ah alright, now I understand what you want, so if you want it to show only for the person that clicked just do (Add this to the first version of the script):
local PartToTween = workspace.CameraRelated.CameraPart
local Properties = {
Position = Vector3.new(20, 25.5, 0)
}
local Tween = TweenService:Create(PartToTween, TweenInformation, Properties)
Now, if you want it to tween for everyone in the server you will need to use a RemoteEvent | Roblox Creator Documentation .
should the script look like this?
samjay22
(Dev)
July 31, 2021, 9:08pm
#12
You cant store a vector as a dict key.
Sarchyx
(Sarchyx)
July 31, 2021, 9:09pm
#13
No, use a LocalScript inside of the button as before and use script.Parent to refer to it:
script.Parent.MouseButton1Click:Connect(function()
end)
thanks it works now! I appreciate it a lot.
1 Like
whats a dict key? Im not sure I understand.
samjay22
(Dev)
July 31, 2021, 9:12pm
#16
Hash table is the name of the data structure. Data structures and their application in Lua
okay. I will read its as soon as I can.
From,
File
I tried doing this so its location would go to another parts location
But its position goes back to 0,0,0
Also theres a section one part and section one button. This is referring to the part. Camera Related is a folder its inside of.
samjay22
(Dev)
July 31, 2021, 9:18pm
#20
You need to make a new topic, this was marked as solved.