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

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

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

✓ Accepted answer

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.

2 comments

0

THANKS SO MUCH!

0

No problem :)

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