This is the second scripting support ive posted in 5 days. . .yay. . .
anyway, i am trying to make a door open when you hit it with a keycard, BUT (theres always a but), it will not work. at all. i tried to make it print stuff to see where it was stuck and i got the answer. . .
print("1")
local parkAccessories = game.Workspace:FindFirstChild("Park Accesories")
local Part = parkAccessories:FindFirstChild("KeycardDoor").DoorPart
local keycardDoor = parkAccessories:FindFirstChild("KeycardDoor")
local slide = keycardDoor:FindFirstChild("Slide")
local TweenService = game:GetService("TweenService")
local TweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
1,
false,
1
)
local goal = {Position = keycardDoor:FindFirstChild("DoorOpen").Position}
local reverseGoal ={Position = keycardDoor:FindFirstChild("DoorClose").Position}
local Tween = TweenService:Create(Part, TweenInfo, goal)
local reverseTween = TweenService:Create(Part, TweenInfo, reverseGoal)
print("2")
slide.Touched:Connect(function(hit)
if hit.Parent.Name == "Keycard" then
print("3")
Tween:Play()
wait(3)
reverseTween:Play()
print("4")
end
end)
it only gets to “1”
i cant figure out why it will not work the rest of the way. i have spent many days trying to figure this out.
what am i doing wrong???
It can help you where the script is failing and pinpoint:
print("1")
local parkAccessories = game.Workspace:FindFirstChild("Park Accesories")
if not parkAccessories then
warn("Park Accesories not found in Workspace")
return
end
local keycardDoor = parkAccessories:FindFirstChild("KeycardDoor")
if not keycardDoor then
warn("KeycardDoor not found in Park Accesories")
return
end
local Part = keycardDoor:FindFirstChild("DoorPart")
if not Part then
warn("DoorPart not found in KeycardDoor")
return
end
local slide = keycardDoor:FindFirstChild("Slide")
if not slide then
warn("Slide not found in KeycardDoor")
return
end
local TweenService = game:GetService("TweenService")
local TweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
1,
false,
1
)
local goal = keycardDoor:FindFirstChild("DoorOpen")
if not goal then
warn("DoorOpen not found in KeycardDoor")
return
end
local reverseGoal = keycardDoor:FindFirstChild("DoorClose")
if not reverseGoal then
warn("DoorClose not found in KeycardDoor")
return
end
local Tween = TweenService:Create(Part, TweenInfo, {CFrame = goal.CFrame})
local reverseTween = TweenService:Create(Part, TweenInfo, {CFrame = reverseGoal.CFrame})
print("2")
slide.Touched:Connect(function(hit)
print("Slide touched")
if hit.Parent and hit.Parent.Name == "Keycard" then
print("3")
Tween:Play()
wait(3)
reverseTween:Play()
print("4")
else
print("Touched by: " .. tostring(hit.Parent.Name))
end
end)
i tried this and it got to “4” but the tweens didnt play and there were no warnings
edit: i made some changes and figured out that the tweens dont work, i guessed that before but now i have confirmation. still cant figure out why they dont work
-- this script is in ServerScriptService
print("1")
local Part = game.Workspace["Park Accesories"].KeycardDoor.DoorPart
local slide = game.Workspace["Park Accesories"].KeycardDoor.Slide
local TweenService = game:GetService("TweenService")
local TweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
1,
false,
1
)
local goal = game.Workspace["Park Accesories"].KeycardDoor.DoorOpen.Position
local reverseGoal = game.Workspace["Park Accesories"].KeycardDoor.DoorClose.Position
local Tween = TweenService:Create(Part, TweenInfo, goal)
local reverseTween = TweenService:Create(Part, TweenInfo, reverseGoal)
print("2")
slide.Touched:Connect(function(hit)
if hit.Parent.Name == "Keycard" then
print("3")
Tween:Play()
wait(3)
reverseTween:Play()
print("4")
end
end)
Typo in variable name:
It seems like there is a typo in your code where you define the reverseGoal table. You have written Postition instead of Position. This typo might prevent the reverseTween from executing correctly.
print("1")
local Part = game.Workspace["Park Accesories"].KeycardDoor.DoorPart
local slide = game.Workspace["Park Accesories"].KeycardDoor.Slide
local TweenService = game:GetService("TweenService")
local TweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
1,
false,
1
)
local goal = { Position = game.Workspace["Park Accesories"].KeycardDoor.DoorOpen.Position }
local reverseGoal = { Position = game.Workspace["Park Accesories"].KeycardDoor.DoorClose.Position }
local Tween = TweenService:Create(Part, TweenInfo, goal)
local reverseTween = TweenService:Create(Part, TweenInfo, reverseGoal)
print("2")
slide.Touched:Connect(function(hit)
if hit.Parent.Name == "Keycard" then
print("3")
Tween:Play()
wait(3)
reverseTween:Play()
print("4")
end
end)