Hello, can you help me to make opening wall?
What I want to achieve is so when I touch a part, the wall will split and make open
illustration down below:
Before touching the part
After touching the part
My code:
local part = game.Workspace.Part
local rightdoor = game.Workspace.RightDoor
local rightdoorfinish = game.Workspace.RightDoorFinish
local leftdoor = game.Workspace.LeftDoor
local leftdoorfinish = game.Workspace.LeftDoorFinish
local bodyposition1 = game.Workspace.RightDoor.BodyPosition
local bodyposition2 = game.Workspace.LeftDoor.BodyPosition
part.Touched:Connect(function()
print("WWWWWWWWWWWWWWWWWWWW") --to make sure its working, it does work but the function below not working
bodyposition2.Position = leftdoor
wait(2)
bodyposition2.Position = leftdoorfinish
end)
You doesn’t detect what’s actually hitting the wall. You need to add parametr to touched event.
Also you must to change position of bodyPosition, through instances position instead instance.
local part = game.Workspace.Part
local rightdoor = game.Workspace.RightDoor
local rightdoorfinish = game.Workspace.RightDoorFinish
local leftdoor = game.Workspace.LeftDoor
local leftdoorfinish = game.Workspace.LeftDoorFinish
local bodyposition1 = game.Workspace.RightDoor.BodyPosition
local bodyposition2 = game.Workspace.LeftDoor.BodyPosition
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
print("WWWWWWWWWWWWWWWWWWWW") --to make sure its working, it does work but the function below not working
bodyposition2.Position = leftdoor.Position
wait(2)
bodyposition2.Position = leftdoorfinish.Position
end
end)
local TweenService = game:GetService("TweenService")
local part = script.Parent
local leftdoorfinish = game.Workspace.LeftDoorFinish
local Info = TweenInfo.new(
1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.InOut,
0,
false,
0
)
local properties = {
Position = leftdoorfinish.Position
}
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid")then
local tween = TweenService:Create(part, Info, properties)
tween:Play()
end
end)
I am glad, i could to help you. Don’t give up. Every scripter learns from his mistakes. If you don’t know something, just search DeveloperHub or Devforum. If you haven’t found any solution to your problem, just ask in the forum. Nobody knows everything.