Moving Parts Script Error

I don’t understand what’s wrong.
W015: (4,1) Assigning 3 values to 1 variables leaves some values unused

local Left = script.Parent.LeftDoor

local Right = script.Parent.RightDoor

Left.Position = 178.634, 21.326, -188.446

Right.Position = 156.049, 21.326, -188.461

wait(0.1)

Left.Position = 189.209, 21.326, -188.446

Right.Position = 145.181, 21.326, -188.461
2 Likes

Position is a data type and only accepts a Vector3 value. The error that you’re getting makes sense.

local Left = script.Parent.LeftDoor

local Right = script.Parent.RightDoor

Left.Position = Vector3.new(178.634, 21.326, -188.446)

Right.Position = Vector3.new(156.049, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(189.209, 21.326, -188.446)

Right.Position = Vector3.new(145.181, 21.326, -188.461)
1 Like

So I’m trying to make a door that slowly opens when someone touches an invisible part,idk how to make one but here’s what I made so far

local Left = script.Parent.LeftDoor

local Touch = script.Parent.Touch

local Right = script.Parent.RightDoor

Touch:FindFirstChild()

if

Left.Position = Vector3.new(178, 21.326, -188.446)

Right.Position = Vector3.new(156, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(179, 21.326, -188.446)

Right.Position = Vector3.new(155, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(180, 21.326, -188.446)

Right.Position = Vector3.new(154, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(181, 21.326, -188.446)

Right.Position = Vector3.new(153, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(182, 21.326, -188.446)

Right.Position = Vector3.new(152, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(183, 21.326, -188.446)

Right.Position = Vector3.new(151, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(184, 21.326, -188.446)

Right.Position = Vector3.new(150, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(185, 21.326, -188.446)

Right.Position = Vector3.new(149, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(186, 21.326, -188.446)

Right.Position = Vector3.new(148, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(187, 21.326, -188.446)

Right.Position = Vector3.new(147, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(188, 21.326, -188.446)

Right.Position = Vector3.new(146, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(189, 21.326, -188.446)

Right.Position = Vector3.new(145, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(189, 21.326, -188.446)

Right.Position = Vector3.new(145, 21.326, -188.461)

What exactly are you trying to do with this line here? This is a function

There is actually an Event that detects when a certain Part gets touched using the Touched event, it’s pretty straight forward (The Event returns back the Part that it hit, so we can check if the Part hit a Player or not)

Also for the moving, I’d recommend using TweenService :slightly_smiling_face: It’s a more smooth & better way of interpolating the properties of objects, such as the Position

Here’s a sample code I went ahead and worked a bit on in relevance to your script hopefully:

local Left = script.Parent.LeftDoor
local Touch = script.Parent.Touch
local Right = script.Parent.RightDoor

local TweenService = game:GetService("TweenService")
local DB = false

local Info = TweenInfo.new(
	2, --The Duration for how long you want the tween to last
	Enum.EasingStyle.Linear, --Probably the most coolest one, do change the Style of this if you want
	Enum.EasingDirection.Out, --Direction from where you want the tween to start
	0, --Repeat at all? Set to 0 to only play once
	false, --Reverse the Tween after it finishes?
	0 --Delay Time
)

local LeftEndPos = {
	Position = Vector3.new(189, 21.326, -188.446)
}

local RightEndPos = {
	Position = Vector3.new(145, 21.326, -188.461)
}

local LeftTween = TweenService:Create(Left, Info, LeftEndPos)
local RightTween = TweenService:Create(Right, Info, RightEndPos)

Touch.Touched:Connect(function(Hit)
	local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
	
	if Player and not DB then --Sanity checks for both a Player and a debounce cooldown
		DB = true
		LeftTween:Play()
		RightTween:Play()
	end
end)
1 Like

it didn’t work tho,nothing appeared in the output as well

You forgot to set the DB back to false after the Player touches the part :upside_down_face:

how to do so?
(I mean the script btw)

At the end of the .Touched, just type this:

DB = false

However, doesn’t seem to be the problem.

This?

   Touch.Touched:Connect(function(Hit)
    	DB = false
    	local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)

    	if Player and not DB then --Sanity checks for both a Player and a debounce cooldown
    		DB = true
    		LeftTween:Play()
    		RightTween:Play()
    	end
    end)

did you find any problems in the script?

No, try this though, it’s @Jackscarlett 's script with a few print statements and the DB set back to false.

local Left = script.Parent.LeftDoor
local Touch = script.Parent.Touch
local Right = script.Parent.RightDoor

local WaitTime = 2 -- Time to wait before door can be opened again

local TweenService = game:GetService("TweenService")
local DB = false

local Info = TweenInfo.new(
	2, --The Duration for how long you want the tween to last
	Enum.EasingStyle.Linear, --Probably the most coolest one, do change the Style of this if you want
	Enum.EasingDirection.Out, --Direction from where you want the tween to start
	0, --Repeat at all? Set to 0 to only play once
	false, --Reverse the Tween after it finishes?
	0 --Delay Time
)

local LeftEndPos = {
	Position = Vector3.new(189, 21.326, -188.446)
}

local RightEndPos = {
	Position = Vector3.new(145, 21.326, -188.461)
}

local LeftTween = TweenService:Create(Left, Info, LeftEndPos)
local RightTween = TweenService:Create(Right, Info, RightEndPos)

Touch.Touched:Connect(function(Hit) 
        print(Hit.Name.." Touched!"
	local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
	
	if Player and not DB then --Sanity checks for both a Player and a debounce cooldown
print(Player.Name.." Touched!"
		DB = true
		LeftTween:Play()
		RightTween:Play()
                wait(WaitTime)
DB = false
	end
end)

Idk why but it still doesn’t work,the output has no error as well FYI

Sorry, messed up some lines I updated the script

You can’t just tell the script to change it to that you have to use Vector3.new()

local Left = script.Parent.LeftDoor

local Right = script.Parent.RightDoor

Left.Position = Vector3.new(178.634, 21.326, -188.446)

Right.Position = Vector3.new(156.049, 21.326, -188.461)

wait(0.1)

Left.Position = Vector3.new(189.209, 21.326, -188.446)

Right.Position = Vector3.new(145.181, 21.326, -188.461)

still doesn’t work,no error either,is there any possible mistakes I’ve made?

Try commenting the whole code and just adding a random print statement

Also, where is the script located?

in the model containing other parts related

Okay, trying commenting the whole code and just adding a print statement see if it prints to the output

local Left = script.Parent.LeftDoor
local Touch = script.Parent.Touch
local Right = script.Parent.RightDoor

local WaitTime = 2 -- Time to wait before door can be opened again

local TweenService = game:GetService("TweenService")
local DB = false

local Info = TweenInfo.new(
	2, --The Duration for how long you want the tween to last
	Enum.EasingStyle.Linear, --Probably the most coolest one, do change the Style of this if you want
	Enum.EasingDirection.Out, --Direction from where you want the tween to start
	0, --Repeat at all? Set to 0 to only play once
	false, --Reverse the Tween after it finishes?
	0 --Delay Time
)

local LeftEndPos = {
	Position = Vector3.new(189, 21.326, -188.446)
}

local RightEndPos = {
	Position = Vector3.new(145, 21.326, -188.461)
}

local LeftTween = TweenService:Create(Left, Info, LeftEndPos)
local RightTween = TweenService:Create(Right, Info, RightEndPos)

Touch.Touched:Connect(function(Hit) 
	print(Hit.Name.." Touched!")
		local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)

		if Player and not DB then --Sanity checks for both a Player and a debounce cooldown
			print(Player.Name.." Touched!")
				DB = true
				LeftTween:Play()
				RightTween:Play()
				wait(WaitTime)
				DB = false
		end
end)

Do this:

--[[

]]

Put all the code between those brackets and then outside of those brackets add a print statement and tell me if it prints