Hi I am new to the DevFourm and I am working on a game. the point is that when you step on and in visible plate the portal disappears. Any ideas on how I can fix this script? (i am new so be honest is there are dumb mistake or this is in the wrong category )
script:
local portal = script.Parent.portal
local plate = script.Parent[“Pressure plate”]
local walls = script.Parent.wall
local doc = script.Parent[“Dr. James Calimari”]
local function onTouch
if otherPart.Name ~= “Terrian”
walls.wall1.CanCollide = false
walls.wall2.CanCollide = false
walls.wall3.CanCollide = false
portal.Part.Transparency = 1
doc.Transparency = 1
There are quite a few issues with your script.
Here’s a model I made of a swinging door with an OnTouch plate that may enlighten you.
You can remove the hinge, Anchor your door Parts and make sure you name the variables properly.
this could work. I added the connection variable so that it only works once. I don’t know if that’s what you expect
local portal = script.Parent.portal
local plate = script.Parent["Pressure plate"]
local walls = script.Parent.wall
local doc = script.Parent["Dr. James Calimari"]
local connection
local function onTouch (otherPart)
if otherPart.Name ~= "Terrian" then
connection:Disconnect()
walls.wall1.CanCollide = false
walls.wall2.CanCollide = false
walls.wall3.CanCollide = false
portal.Part.Transparency = 1
doc.Transparency = 1
end
end
connection = plate.Touched:Connect(onTouch)
in the explorer you should have something like this
There are many errors here. First of all, your not calling “otherPart”, which will give you a nil value. You also don’t have brackets on the local function onTouch, which you need. You also don’t have “then” after your if statement. Try this and see if it works:
local portal = script.Parent.portal
local plate = script.Parent[“Pressure plate”]
local walls = script.Parent.wall
local doc = script.Parent[“Dr. James Calimari”]
local function OnTouch(Hit)
if Hit.Parent:FindFirstChild(“Humanoid”) then
walls.wall1.CanCollide = false
walls.wall2.CanCollide = false
walls.wall3.CanCollide = false
portal.Part.Transparency = 1
doc.Transparency = 1
end
end
Your model should look like this. Inside of the character is all of the character parts.
Along with that, the script should look like this:
local portal = script.Parent.Portal.Portal
local plate = script.Parent:WaitForChild(“Pressure Plate”)
local walls = script.Parent.Walls
local doc = script.Parent:WaitForChild(“Dr. James Calimari”)
local function OnTouch(Hit)
if Hit.Parent:FindFirstChild(“Humanoid”) then
walls.Wall1.CanCollide = false
walls.Wall2.CanCollide = false
walls.Wall3.CanCollide = false
portal.Transparency = 1
for i,v in pairs(doc:GetChildren()) do
if v:IsA("BasePart") then
v.Transparency = 1
end
end
end