local doororientation = script.Parent.Orientation local doorposition = script.Parent.Position function door () doororientation = Vector3(0, 90, 0) doorposition = Vector3(942, 3.24, -847.38) wait(0.7) doororientation = Vector3(0, 0, 0) doorposition = Vector3(940, 3.24, -847.38) end script.Parent.ClickDetector.MouseClick:Connect(door)
I'm a beginner at coding, as in I started a few days ago, so I was seeing if I could make a better version of my disappearing door. I was messing around, and I assume I did this script correctly, but I obviously did not. I assumed sense
script.Parent.Orientation = Vector3(0, 90, 0)
worked, I could use it inside of a function, with a variable, but as a beginner, I was sadly wrong. :(
Could anyone explain what I did wrong?
The reason why your door isn't moving is that you're talking to the reference of your door. When you reference the property of an object at game start, it simply copies it to memory. so when you change that property, the original doesn't see the change. To fix this, i would change your code to this..
Try this:
local door = script.Parent -- this would make a reference to the object that can be changed later!. -- old -- function door ()-- this needs to be changed -- to something like this function Door() --// make the necessary changes from our reference object aka door door.Orientation = Vector3.new(0, 90, 0) door.Position = Vector3.new(942, 3.24, -847.38) wait(0.7) door.Orientation = Vector3.new(0, 0, 0) door.Position = Vector3.new(940, 3.24, -847.38) end -- wat ever you name your function just change this bit to call it example: -- old -- script.Parent.ClickDetector.MouseClick:Connect(door) -- new script.Parent.ClickDetector.MouseClick:Connect(Door) -- same name as above, including capitalization of the first letter etc...
Hope this helps! :)
You tried using only with 'Vector3'.
It is supposed to be Vector3.new
which returns a Vector3 value by using the 3 values (x,y,z).
Rewrite your code like this:
local doororientation = script.Parent.Orientation local doorposition = script.Parent.Position function door () doororientation = Vector3.new(0, 90, 0) doorposition = Vector3.new(942, 3.24, -847.38) wait(0.7) doororientation = Vector3.new(0, 0, 0) doorposition = Vector3.new(940, 3.24, -847.38) end script.Parent.ClickDetector.MouseClick:Connect(door)
I kind of just released something but it is already answered by the first answer made to this question.