apologies for horrific grammar in title, they only allow 100 characters in it
I have a door (one part, united together) and I have it clickable to open. I felt like doors with hinges were too hard to open by pushing at times, especially on mobile, so I thought a better, efficient way to do so is make it clickable. I wrote a script to change the position and rotation so it'll be function able. However, since I'm new to scripting, several errors occurred when making this.
First of all, when clicked, the door goes on top of the nearest solid brick, let's say a roof, and stays there. I tried to make the 'CanCollide = false' when clicked (of course swapped back to true when it automatically closes), but it still goes on top of the roof, or a player when he/she is standing beside it. I feel like it's Roblox's funky way of putting objects on top of one another, and I know it's possible since ZolarKeth and Gusmanak were able to implement it in 'Urbis'.
Also, I feel like the door should have the ability to close by choice, instead of closing automatically. However, all I know how to do is make it automatic, which makes the game feel more "mechanic".
Here's the code;
local Door = script.Parent
function onClicked(playerWhoClicked)
--opened
Door.Position = Vector3.new(34.6, 12.3, 105.1)
Door.Rotation = Vector3.new(0, -90, 0)
wait(2)
--closed
Door.Position = Vector3.new(32.1, 12.3, 103.4)
Door.Rotation = Vector3.new(0, 0, 0)
end
Door.ClickDetector.MouseClick:connect(onClicked)

3 comments
I will constantly be updating my answer. Please read it.
Edited. Reply back if you have any questions.
I realise how long my answers are nowadays. It takes like 10 seconds to scroll through one of my answers.(Not this one.)