Hey everyone! So today I was working on making my door local so when someone comes and the door is about the close, the debounce doesn’t make them wait because that would be kinda annoying. Everything went smooth with my script, no errors, then when the close tween played, the door didn’t close, only the sound played. It said that argument 3 missing or nil. Not really sure what that means but here is my script.
local TweenService = game:GetService("TweenService")
local detector = game.Workspace.DoorToHouse.Detector
local center = game.Workspace.DoorToHouse.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
detector.Touched:Connect(function(hit)
if hit.Parent:WaitForChild("Humanoid") then
end
if debounce == true then return end
debounce = true
if door == "closed" then
script["Opening Door"]:Play()
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)
script["Closing Door"]:Play()
TweenService:Create(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()
end
wait(1)
debounce = false
end)
If anyone knows how to fix this, please leave a comment.
What do you mean I am not specifying which instance? I’m new to Lua, so if you could make it so I could understand as a beginner, then that would be great :))
I know this isn’t your problem, but using WaitForChild() will infinite yield if the humanoid hasn’t loaded yet. So, I recommend using FindFirstChild().
He means you didn’t provide the object to tween in the first parameter lol.
-- Opening the door
TweenService:Create(CF, TweenInfo.new... -- Provides the door
-- Closing the door
TweenService:Create(TweenInfo.new... -- Doesn't provide the door
Should be a smidge easier to spot now lol.
EDIT
Noticed this when reading over the code, you didn’t set door back to closing, thus when the script’s ready to execute again it however wont open the door upon touched.