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!
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.