Lockdown Script Issue

If you can, send a video of the door moving, please.

I can’t since it’s not moving…

At least a screenshot? (3-0 chars)

Or maybe remove the “if player:GetRankInGroup” statement and test it.

image
Here it is. The highlighted part at the top is the door. The grey platform is where it’s tweening to.

I’m higher than rank 5 in the group, so that shouldn’t be a problem. Also, I tested by removing every line except for the Tween:Play(), and it wasn’t playing still.

Hmm… lemme just read all the code and see if I find any error.

1 Like

Try this:

local tweenService = game:GetService("TweenService")

local openTween = tweenService:Create(Part, TweeningInfo, {Position = Pos1})
local closeTween = tweenService:Create(Part, TweeningInfo, {Position = PosToTween})

-- play the tweens and y'now

I don’t know if it will change anything but I hope it does work

1 Like

It’s not working :frowning_face:

Well, I’m sorry I could’t help (for now) but I hope you fix it, good luck!

1 Like

Hold on, a change in material of the part I’m tweening to wouldn’t change anything, right?

Nope, make sure the door is anchored tho.

I should probably test this for me, but usually when I want to tween a position of a part like a door, when you input the properties you wanna change (the Position in this case) I usually have to do it like this:

local Tween1 = TweenService:Create(Part, TweeningInfo,{Position = Part.Position + PositionIWantToEndUpIn})

and when I want to let’s say, animate the door to close back, i have to just make a minor change

local Tween2 = TweenService:Create(Part, TweeningInfo,{Position = Part.Position})

Maybe it’s the case for you too, just try adding the position you want the door to end up in to it’s current position.

Thanks for your reply, but the strangest thing is that the door closes when I put it in a while true do loop. Also, I think your first line implies that the door would move the distance from the position you are tweening + the part’s current position (might be wrong).

I have no clue why it plays if its in a loop to be honest. Very strange.

So the first line just says that I want to move the part that im tweening from it’s current position to the position of the other part or a brand new Vector3 value. The second line just tweens it back to it’s original position.

At this point you might as well rewrite the whole code

:laughing: That’s pretty true. I was new to tween service when I first created this, still worked.

Alright, will try.

1 Like

It prints Enum.PlaybackState.Completed

Bumping post. Still has not been solved.

May I rewrite all the script? (3-0 chars)

Alright, I modified your code a “bit”, hope it works!

Code:

local Part = script.Parent
local Settings = require(script:WaitForChild("Settings"))
local Model = workspace:WaitForChild("CautionModel")
local Pos1 = Part.Position
local GroupID = 9395780
local Detector = workspace.ButtonHolder.WaitForChild("Button").ProximityPrompt
local OpenButton = workspace.OpenButton:WaitForChild("Button").ProximityPrompt
local db = false
local Open = true
local WaitTime = Settings.WaitTime
local Compressing = false
local Alarm = Part:WaitForChild("Alarm")
local PosToTween = Model.ChosenModel.ChosenTModel:WaitForChild("Wedge").Position
local TweenService = game:GetService("TweenService")

local TweeningInfo = TweenInfo.new(
	30,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)

local Tween1 = TweenService:Create(Part, TweeningInfo, {Position = Pos1})
local Tween2 = TweenService:Create(Part, TweeningInfo, {Position = PosToTween})

function ToggleDoor()
	if Open then
		Tween1:Play()
		Compressing = true
		Alarm:Play()
		print("Closing...")
		wait(14)
		Compressing = false
		Tween1.Completed:Wait()
		wait(WaitTime)
	else
		Tween2:Play()
		Compressing = false
		Alarm:Stop()
		print("Opening...")
		Tween2.Completed:Wait()
		wait(WaitTime)
	end
	Open = not Open
end

Detector.Triggered:Connect(function(Player)
	if Player:GetRankInGroup(GroupID) >= 5 then
		if not db then
			db = true
			ToggleDoor()
			db = false
		end
	end
end)

Part.Touched:Connect(function(Hit)
	local Character = Hit.Parent:FindFirstChild("Humanoid")
	if Character then
		print(Character.Parent.Name.." touched the door!")
		if Compressing then
			print("Killing "..Character.Parent.Name)
			Character.Health = 0
		end
	end
end)

OpenButton.Triggered:Connect(function(Player)
	if Player:GetRankInGroup(GroupID) >= 5 then
		if not db and not Open then
			db = true
			ToggleDoor()
			db = false
		else
			print(Player.Name.." cannot interact!")
		end
	end
end)

Also

Make sure the settings module is for example like this:

local module = {

    WaitTime = 10;

    -- blah blah

}

return module

And not like this:

local module = {}

WaitTime = 10

-- blah blah

return module

If you get what I mean.