Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I make a different script function upon standing on a brick?

Asked by 10 years ago

Im trying to make a door open upon standing on a brick. The door opens using this script:

p=game.Workspace.Part2

for i=1,29 do wait(.02) p.CFrame=p.CFrame+Vector3.new(0,0,.5) wait() end

How would I make that script only run when a different brick is touched?

I'm quite new to scripting, it's been a while since i've been a roblox so thanks for any help!

1 answer

Log in to vote
1
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
10 years ago

You can do this all in one script actually! You just need to call the touched event on the part you stand on and then run the your door opening code.

local part = script.Parent -- Part to step on
local door = game.Workspace.Part2 -- Door

local open = false

part.Touched:connect(function(hit)
    if hit:findFirstChild('Humanoid') and hit:findFirstChild('Torso') then
        if not open then
            for i = 1, 29 do
                door.CFrame = Door.CFrame + Vector3.new(0, 0, 0.5)
                wait(0.02)
            end
        end
    end
end)

You might also want to add some door closing code using the TouchEnded event aswell.

0
THANKS SO MUCH! Arkantos12345 5 — 10y
0
No problem :) BlackJPI 2658 — 10y
Ad

Answer this question