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

How to make a trigger brick?

I have a transparent brick and when it is touched by a player. I want 2 bricks which are in the workspace to move with cframe but when I try it, it does not work!

Trigger has a touch intrest in it but when I touch it the intrest goes away! Help!

I tried this.

function onTouched(hit)  
	script.Parent.Parent.Wall1.CFrame = script.Parent.Wall1.CFrame + Vector3.new(0,0,1)
	script.Parent.Parent.Wall2.CFrame = script.Parent.Wall2.CFrame + Vector3.new(0,0,-1)
	end
	
script.Parent.Touched:connect(onTouched)

I'm awful at scripting!

1 comment

0

I don't know much, but my guess is that your vector3's need to be CFrames and you need denounce within the function.

2 answers

✓ Accepted answer

touch interest is not important just so you know.

you also forgot a Parent in your variables

Here's a script that might help.

script.Parent.Touched:connect(function(hit) 		--Fires the touched event
	if hit.Parent:FindFirstChild("Humanoid") then	--making sure it's a player
		script.Parent.Parent.Wall1.CFrame = script.Parent.Parent.Wall1.CFrame + Vector3.new(0,0,1)
		script.Parent.Parent.Wall2.CFrame = script.Parent.Parent.Wall2.CFrame - Vector3.new(0,0,1)
	end
end)

1 comment

0

script.Parent.Touched:connect(function(hit) --Fires the touched event if hit.Parent:FindFirstChild("Humanoid") then --making sure it's a player for i= 1,600 do script.Parent.Parent.Wall1.CFrame = script.Parent.Parent.Wall1.CFrame + Vector3.new(0,0,0.1) script.Parent.Parent.Wall2.CFrame = script.Parent.Parent.Wall2.CFrame - Vector3.new(0,0,0.1) end Line 3 is red!

script.Parent.Touched:connect(function(hit)   --Fires the touched event
if hit.Parent:FindFirstChild("Humanoid") then --making sure it's a player 
	for i= 1,600 do
        script.Parent.Parent.Wall1.CFrame = script.Parent.Parent.Wall1.CFrame + Vector3.new(0,0,0.1)
        script.Parent.Parent.Wall2.CFrame = script.Parent.Parent.Wall2.CFrame - Vector3.new(0,0,0.1)
    end

Line 3 red :( Halp

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