Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

TweenService:Create failed because Instance is null?

I have a simple tween script for a door I'm working on and it's giving me an error, but I do not know why. Any help is appreciated!

TweenService = game:GetService("TweenService")

script.Parent.Open.Changed:Connect(function()
	if script.Parent.Lockdown.Value == false then
		if script.Parent.Open.Value == true then
			local Info = TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)
			TweenService:Create(script.Parent.Door.PrimaryPart, Info, {CFrame = script.Parent.Positions.Opened.CFrame}):Play()
			script.Parent.Door.PrimaryPart.OpenClose:Play()

		elseif script.Parent.Open.Value == false then
			local Info = TweenInfo.new(11, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out, 0, false, 0)
			TweenService:Create(script.Parent.Door.PrimaryPart, Info, {CFrame = script.Parent.Positions.Closed.CFrame}):Play()
			script.Parent.Door.PrimaryPart.OpenClose:Play()
			wait(0.8)

		elseif script.Parent.Lockdown.Value == true then
			if script.Parent.Open.Value == true then
				local Info = TweenInfo.new(0.01, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)
				TweenService:Create(script.Parent.Door.PrimaryPart, Info, {CFrame = script.Parent.Positions.Opened.CFrame}):Play()
				script.Parent.Door.PrimaryPart.OpenClose:Play()
				script.Parent.Lockdown.Value = false

			elseif script.Parent.Open.Value == false then
				local Info = TweenInfo.new(.1, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out, 0, false, 0)
				TweenService:Create(script.Parent.Door.PrimaryPart, Info, {CFrame = script.Parent.Positions.Closed.CFrame}):Play()
				script.Parent.Door.PrimaryPart.EmergencyClose:Play()
				script.Parent.Lockdown.Value = false
				wait(0.8)
				
			end
		end	
	end 
end)

1 answer

✓ Accepted answer

I'm not entirely sure what the issue is because I cant see the hierarchy, but my best guess is theres no primary part or this door object is null, perhaps its cancollide off and anchored false? I don't know, but the "instance is null" error is usually caused by something that is nonexistant or has been deleted. Good luck and I hope you find a proper answer soon!

1 comment

0

Thank you! I just noticed there was no primary part!

This discussion is preserved as it was. New answers, comments, and votes are closed.