How to make a wall open

I’m confused on one thing. I do not know how to script to make it open. and I’m little confused tho as well. I need some help.

4 Likes

We need more info. How exactly do you want it to open. When do you want it to open. Also, have you tried to make it work, or looked it up already.

1 Like

Like a door, like when it’s open it will lift.

1 Like

So you want it to go up, correct?
How do you want this door to be triggered? (Button press, touch the door, etc.)

1 Like

button press, Because it’s will be more easy

1 Like

Hi, @NinjaClanGreenNinja. I believe what you want to do is tween the door.

1 Like

like to open it? Because it’s so confused for a wall

We need a lil bit more info on your end goal here :sweat_smile:
If youre looking on moving any part in the form of a button press I would reccomend looking into Tweening and Bindable Events.

1 Like

will the work for opening walls?

Here you go:

Step 1
Make a part near your wall/door, this will be the button part. Click the plus button next to the part icon (when hovering) or right click and click insert object. Search for ClickDetector and insert. Next repeat the process except instead of a ClickDetector insert a Script.

Step 2
So now it’s time to make the script.
Delete everything that’s already in the script and add the following:

local wall = game.Workspace.YourWallsName
local ogY = wall.Position.Y

local detector = script.Parent.ClickDetector

local TS = game:GetService("TweenService")
local info = TweenInfo.new(1)

detector.MouseClick:Connect(function()
    local open = wall.Positon.Y ~= ogY
    local goal = {}
    if open then
        goal.Position = Vector3.new(wall.Position.X, ogY, wall.Position.Z)
    else
        goal.Position = Vector3.new(wall.Position.X, ogY+10, wall.Position.Z)
    end
    local tween = TS:Create(wall, info, goal)
    tween:Play()
end)

You need to replace YourWallsName with, well, the name of your wall

It’s just call wall, That why?

Yes, replace

With wall

30

It’s not opening still… I do not know why

As @domboss37, you can use MouseClick events (RBXSIGNALS), and tween service to do this.

You can create 2 parts, 1 is the wall, the other is the button. After that, you can create a ClickDetector, which is what you will use to click the button. (parent the clickdetector to the button.)

After, you just need to now create a toggle function, and tweening. Code;

parent the code in the click detector

local opened = false
local wall = script.Parent.Parent.Parent.Wall -- put the name to anything, has to match with the instance.

local function tween(object, number, goal)
 local main = coroutine.wrap(function()
local tween = game:GetService("TweenService"):Create(object, TweenInfo.new(number), goal)
tween:Play()
tween.Completed:Wait()
tween:Destroy()
end)
main()
end

local function Open()
 tween(wall, 2, {Position = wall.Position + Vector3.new(0, 10, 0)})
end

local function Close()
 tween(wall, 2, {Position = wall.Position - Vector3.new(0, 10, 0)})
end

script.Parent.MouseClick:Connect(function()
 if opened == false then
opened = true
Open()
else
opened = false
Close()
end
end)

Explorer looks sometihng like this:

image

1 Like

So, all in all script? Because I do not get it

Any errors still??? Or is it just not working?

Yes, all in one.

Firstly, it will have a bool, and is off. If the Mouse is clicked, it will run a function, (using MouseClick), if statements to check if the bool is false or not, aka a toggle bool. It will play “Open”, to lift the wall up, and “Close”, to lift it down.

Okay, I will try it when I get back home