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

The script won't detect the variable?

Hey. I'm making a door tween in Roblox, but when I try to define the variables to create a tween, it will put a line under it says it does not exist. Here's my script :

script.Parent.MouseClick:Connect(function()
	
	if script.Parent.Parent.BrickColor == BrickColor.new("Lime green") then
		
		script.Parent.Parent.BrickColor = BrickColor.new("Really red")
		
		 local tweenService = game:GetService("TweenService") --Variable to the service.
		
		 local Part1 = game.Workspace.PartDoor1 --Variable to a door.
		
		
		 local tweenInfo = TweenInfo.new(
		 	 3,
		   	 Enum.EasingStyle.Quad,
			 Enum.EasingDirection,
			 1, 
			 true,
			 2
			)
		end
	
	
	local Goals = {
		

		Position = Vector3.new(-49.346, 4.165, -117.723)
		
	}
	
	local tween = tweenService:Create(Part1, tweenInfo, Goals) --It won't detect Part1 and 	 
        tweenInfo.


	tween:Play()
	
end)

Any help?

1 answer

✓ Accepted answer

Have you tried putting the 2 variables at the top before the 'if' statement? Try that and see if it works.

script.Parent.MouseClick:Connect(function()

    local tweenService = game:GetService("TweenService") --Variable to the service.
    local Part1 = game.Workspace.PartDoor1 --Variable to a door.

    if script.Parent.Parent.BrickColor == BrickColor.new("Lime green") then

        script.Parent.Parent.BrickColor = BrickColor.new("Really red")

         local tweenInfo = TweenInfo.new(
             3,
             Enum.EasingStyle.Quad,
             Enum.EasingDirection,
             1, 
             true,
             2
            )
        end


    local Goals = {


        Position = Vector3.new(-49.346, 4.165, -117.723)

    }

    local tween = tweenService:Create(Part1, tweenInfo, Goals) --It won't detect Part1 and   
        tweenInfo.


    tween:Play()

end)

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