Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to rotate a "Door" Model by touching it?

I have this basement and I want it where you touch it and the door rotates 90 degrees if I am correct, I have no idea what script I would use for this because I am a beginner scripter but I also have a script that is close I think, Check this out

function onTouch(hit) if hit.Parent.Name == "Door" then game.Workspace.Door.CFrame=CFrame.new(1,10,1) end end script.Parent.Touched:connect(onTouch

Plz halp

Here is a picture of the door

https://gyazo.com/12e6360088e167cfc7156d381b55d7b7

1 answer

✓ Accepted answer

Hey! I see you're having a problem with your door and I will gladly fix it, but if you can do me a favor, please union that door. It would make stuff a lot easier.

function onTouch(hit)
    if hit.Parent:FindFirstChild("Humanoid") then --Checks if the thing that hit it is a player
        for i=0,80, 1 do --a loop that repeats it for a specific amount of times.
	            	game.Workspace.Door.Rotation = game.Workspace.Door.Rotation + Vector3.new(0, i, 0) --If you were to do Door.CFrame then it would have to be CFrame.new, why? Because you cant add a Vector3 value to a CFrame value.		
		wait(0.1)--waits a tenth of a second.
        end
    end
end

script.Parent.Touched:connect(onTouch)

Although you can use a script for this, the best way to do this would be to use surfaces. A specific surface would be a "Hinge".

8 comments

0

It wasn't the right rotation so I changed it but when I did every time I walked into it, It crashed my game, Even when I changed it to something else, First it was a ANTI-LAG script but when I disabled that it was your script, Doesn't work

0

There is no such thing as anti-lag scripts, and fyi but this as a regular script inside the door thing. Shouldnt be crashing your game though.

0

Wait, I truly apologize. Let me edit my post, I know why its lagging or "crashing" the game.

0

What happen when I touch it or change the rotation https://gyazo.com/3836ab330b918cd4d5f5c0902ff71fdf

0

Can you please give me the Rotation value of the door? Thanks! :)

0

Rotation value? Do you mean the (0, i, 0)? I will tell you both, So first time without change it did the same in the GIF and second time I changed it to for i=0,80, 0 do and (0, i, 0) and it did the same, Then I changed it for i=0,80, 0 do and (0, 1, 0) And it did the same thing.

0

Or if you mean what rotation the door is in right now it is " -179.148, -0.003, 179.397 "

0

Thank you, sorry I was sleeping. I will fix the script, give me a second :)

This discussion is preserved as it was. New answers, comments, and votes are closed.