I am so confused, why doesn't this work?

It has nothing in the console, I am so confused, it doesn’t print, doesn’t do anything I am just tryin gto open a door

local TouchPart = script.Parent:FindFirstChild("TouchPart")

if TouchPart == nil then
	warn("Missing touch part")
end

local groupId = script:GetAttribute("groupId")
local groupId2 = script:GetAttribute("groupId2")

local groupRank = script:GetAttribute("groupRole")
local groupRank2 = script:GetAttribute("groupRole2")

local blastDoorTweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0.5)
-- Functions --


function TweenDoor (targetedDoor, tweenInfo, targetedDoor2)
	print("Worked!")
	
		local blastTween = TweenService:Create(targetedDoor, tweenInfo, {Position = targetedDoor.Position + Vector3.new(0, targetedDoor.Size.Y, 0)})
		
		blastTween:Play()
end

TouchPart.Touched:Connect(function(hit)
	local player = Players:GetPlayerFromCharacter(hit.Parent or hit.Parent.Parent)
	
	if player then
		if groupId and groupId2 ~= 0 then
			if player:IsInGroup(groupId) and player:IsInGroup(groupId2) then
				if groupRank ~= 0 then
					if player:GetRankInGroup(groupId) >= groupRank then
						if groupRank2 ~= 0 then
							if player:GetRankInGroup(groupId2) >= groupRank then
								TweenDoor(script.Parent:WaitForChild("Door"), blastDoorTweenInfo)
							end
						end
					end
					
				end
			end
		elseif groupId ~= 0 then
			if groupRank ~= 0 then
				if player:GetRankInGroup(groupId) >= groupRank then
					TweenDoor(script.Parent:WaitForChild("Door"), blastDoorTweenInfo)
				end
			else
				TweenDoor(script.Parent:WaitForChild("Door"), blastDoorTweenInfo)
			end
		end
	end
end)
1 Like

Are you using a script or a localscript?

I am using an script inside of the model

Put a print statement at the top of the script to make sure it is running, and then put more print statements after each event and “if” to see how far it is getting, and to see where it stops working as expected.

It gets to just after this even without me hitting the part?

Maybe the part is unanchored and it is touching other parts. Or maybe other unanchored parts are touching it.

1 Like