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

How to make a trigger brick?

Asked by
Nidoxs 190
10 years ago

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!

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. GoldenPhysics 474 — 10y

2 answers

Log in to vote
0
Answered by
Marolex 45
10 years ago

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)
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! Nidoxs 190 — 10y
Ad
Log in to vote
0
Answered by
Nidoxs 190
10 years ago
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

Answer this question