I don’t understand why my door isn’t working. I did the same exact script as I did with my other door. So basically when a person goes through my door, it opens for them, it worked for my other door, but for this door it isn’t. Can anyone help me? the center part is welded to the door, and the center part is anchored. I am not sure if the weld part is the other way around lol, prob is… here is my script
local TweenService = game:GetService("TweenService")
local center = game.Workspace.Door5.Center
local door = "closed"
local CF = Instance.new("CFrameValue")
CF.Value = center.CFrame
CF.Changed:Connect(function()
center.CFrame = CF.Value
end)
local debounce = false
script.Parent.Detector.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
end
if debounce == true then return end
debounce = true
if door == "closed" then
TweenService:Create(CF, TweenInfo.new(0.5,Enum.EasingStyle.Back,Enum.EasingDirection.Out), {Value = center.CFrame * CFrame.Angles(math.rad(0), math.rad(-100), math.rad(0))}):Play()
door = "open"
wait(5)
TweenService:Create(CF, TweenInfo.new(0.5,Enum.EasingStyle.Back,Enum.EasingDirection.Out), {Value = center.CFrame * CFrame.Angles(math.rad(0), math.rad(100), math.rad(0))}):Play()
door = "closed"
end
wait(1)
debounce = false
end)
if you know why this is happening, please leave a comment.
I don’t really know whats the issue but, I think your statement which checks if the hit’s Parent has a Humanoid, should be wrapped around the rest of the code. Or simply return if its false.
script.Parent.Detector.Touched:Connect(function(hit)
if not hit.Parent:FindFirstChild("Humanoid") then return end
if debounce == true then return end
debounce = true
if door == "closed" then
TweenService:Create(CF, TweenInfo.new(0.5,Enum.EasingStyle.Back,Enum.EasingDirection.Out), {Value = center.CFrame * CFrame.Angles(math.rad(0), math.rad(-100), math.rad(0))}):Play()
door = "open"
wait(5)
TweenService:Create(CF, TweenInfo.new(0.5,Enum.EasingStyle.Back,Enum.EasingDirection.Out), {Value = center.CFrame * CFrame.Angles(math.rad(0), math.rad(100), math.rad(0))}):Play()
door = "closed"
end
wait(1)
debounce = false
end)
Would also recommend placing a print statement inside the Touched block to check till where its running.
I got no errors, I also did the print, and I did touch the detector but nothing happened with the tween… Here I will show you guys my workspace.
the door is not anchored, the center part is… The detector is anchored as well. The weld constraint, has door as part0 and as part1 is center. I don’t know if those need to be switched around but I tried both ways.