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

Glass changing orientation for no reason?

I wrote this code:

local Teams = script.Parent.Teams
local LDL3 = game.ReplicatedStorage.Lockdowns.LD3Activated
local LDL4 = game.ReplicatedStorage.Lockdowns.LD4Activated
local LLD = game.ReplicatedStorage.Lockdowns.LLDActivated
local RAID = game.ReplicatedStorage.Lockdowns.RAIDActivated
local Moving = false
local Reader1 = script.Parent.Reader1.CardReader
local Reader2 = script.Parent.Reader2.CardReader
local frame = script.Parent.Union
local glass = script.Parent.Glass
local Shutter = script.Parent.Door
local opensound = Shutter.Open
local closesound = Shutter.Close
local TweenService = game:GetService("TweenService")
local Perms = {
	["Prison Command"] = Teams["Prison Command"].Value,
	["Prison Administration"] = Teams["Prison Administration"].Value,
	["Emergency Response Team"] = Teams["Emergency Response Team"].Value,
	["Medical Staff"] = Teams["Medical Staff"].Value,
	["Military Police"] = Teams["Military Police"].Value,
	["Government Staff"] = Teams["Government Staff"].Value,
	["Facility Officers"] = Teams["Facility Officers"].Value,
	["Special Forces"] = Teams["Special Forces"].Value,
	["Inmate"] = Teams["Inmate"].Value,
	["Max Security Inmate"] = Teams["Max Security Inmate"].Value,
	["Supermax Inmate"] = Teams["Supermax Inmate"].Value,
	["[CLASSIFIED]"] = Teams["[CLASSIFIED]"].Value,
	["Hostile Forces"] = Teams["Hostile Forces"].Value,
	["Nervex Security"] = Teams["Nervex Security"].Value,
	["Moderation Team"] = Teams["Moderation Team"].Value,
	["Southside New's"] = Teams["Southside New's"].Value,
	["CPU"] = Teams["CPU"].Value,
	["[EXPUNGED]"] = Teams["[EXPUNGED]"].Value,
	["Engineering and Technical"] = Teams["Engineering and Technical"].Value
}

local tweeningInformation = TweenInfo.new(
	1,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)

local doorclose = {CFrame = Shutter.CFrame + (Shutter.CFrame.lookVector * 0)}
local doortweenclose = TweenService:Create(Shutter,tweeningInformation,doorclose)
local dooropen = {CFrame = Shutter.CFrame + (Shutter.CFrame.lookVector * 3)}
local doortweenopen = TweenService:Create(Shutter,tweeningInformation,dooropen)
local glassclose = {CFrame = glass.CFrame + (glass.CFrame.lookVector * 0)}
local glasstweenclose = TweenService:Create(glass,tweeningInformation,doorclose)
local glassopen = {CFrame = glass.CFrame + (glass.CFrame.lookVector * 3)}
local glasstweenopen = TweenService:Create(glass,tweeningInformation,dooropen)
local frameclose = {CFrame = frame.CFrame + (frame.CFrame.lookVector * 0)}
local frametweenclose = TweenService:Create(frame,tweeningInformation,doorclose)
local frameopen = {CFrame = frame.CFrame + (frame.CFrame.lookVector * 3)}
local frametweenopen = TweenService:Create(frame,tweeningInformation,dooropen)

function open(Plr)
	if Perms[Plr.Team.Name] then
		if script.Parent.Open.Value == false then
			if Moving == false then
				script.Parent.Open.Value = true
				Moving = true
				doortweenopen:Play()
				glasstweenopen:Play()
				frametweenopen:Play()
				opensound:Play()
			wait(1)
				Moving = false
			end
		end
	end
end

function close(Plr)
	if Perms[Plr.Team.Name] then
		if script.Parent.Open.Value == true then
			if Moving == false then
				script.Parent.Open.Value = false
				Moving = true
				doortweenclose:Play()
				glasstweenclose:Play()
				frametweenclose:Play()
				closesound:Play()
			wait(1)
				Moving = false
			end
		end
	end
end

Reader1.Clicker.MouseClick:Connect(open)
Reader1.Clicker.MouseClick:Connect(close)
Reader2.Clicker.MouseClick:Connect(open)
Reader2.Clicker.MouseClick:Connect(close)

LDL3.Changed:Connect(function()
	if LDL3.Value == true then
		if script.Parent.Open.Value == true then
			script.Parent.Open.Value = false
			Moving = true
			doortweenclose:Play()
			glasstweenclose:Play()
			frametweenclose:Play()
			closesound:Play()
			closesound:Play()
		wait(1)
			Moving = false
		end
	end
end)

LDL4.Changed:Connect(function()
	if LDL4.Value == true then
		if script.Parent.Open.Value == true then
			script.Parent.Open.Value = false
			Moving = true
			doortweenclose:Play()
			glasstweenclose:Play()
			frametweenclose:Play()
			closesound:Play()
			closesound:Play()
		wait(1)
			Moving = false
		end
	end
end)

LLD.Changed:Connect(function()
	if LLD.Value == true then
		if script.Parent.Open.Value == true then
			script.Parent.Open.Value = false
			Moving = true
			doortweenclose:Play()
			glasstweenclose:Play()
			frametweenclose:Play()
			closesound:Play()
			closesound:Play()
		wait(1)
			Moving = false
		end
	end
end)

RAID.Changed:Connect(function()
	if RAID.Value == true then
		if script.Parent.Open.Value == true then
			script.Parent.Open.Value = false
			Moving = true
			doortweenclose:Play()
			glasstweenclose:Play()
			frametweenclose:Play()
			closesound:Play()
			closesound:Play()
		wait(1)
			Moving = false
		end
	end
end)

And the door does this. I don't understand why.

https://youtu.be/-w1H4RehNhc

1 comment

0

Copy that link and paste it into your browser to see what it does.

1 answer

✓ Accepted answer

instead of using the tween goals for each separate part, you're using dooropen and doorclose for all of them. fix that and it should work

btw, instead of making a separate tween for each part of the door, you can weld everything to the "main" door part using a WeldConstraint, make them unanchored, and just tween said door part

btw btw the Perms thing can be accomplished so much more easily with a simple for loop

local Perms = {}
for _, val in pairs(Teams:GetChildren()) do
	Perms[val.Name] = val.Value
end

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