There is no error from what I can see. Here is my code, really need help, I am stuck.
-- Services --
local Players = game:GetService("Players")
local GroupService = game:GetService("GroupService")
local TweenService = game:GetService("TweenService")
-- Variables --
local Text1 = script.Parent:WaitForChild("Door"):WaitForChild("Text1")
local Text2 = script.Parent:WaitForChild("Door"):WaitForChild("Text2")
--local Door = script.Parent:WaitForChild("Door")
local TouchPart = script.Parent:WaitForChild("TouchPart", 60)
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, true, 0.5)
-- Functions --
function checkGroupRank(target, groupId, groupId2, minGroupRank, minGroupRank2)
if groupId then
if groupId2 then
local isIn1 = target:IsInGroup(groupId)
local isIn2 = target:IsInGroup(groupId2)
if isIn2 and isIn1 then
local groupRank = target:GetRankInGroup(groupId)
local groupRank2 = target:GetRankInGroup(groupId2)
return isIn2, isIn2, groupRank, groupRank2
elseif isIn1 then
local groupRank = target:GetRankInGroup(groupId)
return isIn1, groupRank
elseif isIn2 then
local groupRank2 = target:GetRankInGroup(groupId2)
return isIn2, groupRank2
end
else
local isIn1 = target:IsInGroup(groupId)
if isIn1 == true then
local groupRank = target:GetRankInGroup(groupId)
if minGroupRank ~= nil then
if groupRank >= minGroupRank then
return isIn1, groupRank
end
else
print("No minGroupRank")
return isIn1
end
end
end
end
end
--[[Players.PlayerAdded:Connect(function(player)
end)
]]
function searchForInName(object)
local objectName = object.Name
print(objectName)
if string.find(objectName, "Blast") then
return "Blast"
elseif string.find(objectName, "Slide") then
return "Slide"
elseif string.find(objectName, "Swing") then
return "Swing"
elseif string.find(objectName, "DepsSlide") then
return "DepsSlide"
end
end
function getDoor(doorType)
if doorType == "Blast" then
local Door = script.Parent:FindFirstChild("Door")
return Door
elseif doorType == "Slide" then
local Door1 = script.Parent:FindFirstChild("Gate1")
local Door2 = script.Parent:FindFirstChild("Gate2")
return Door1, Door2
elseif doorType == "Swing" then
local Door1 = script.Parent:FindFirstChild("Gate1")
local Door2 = script.Parent:FindFirstChild("Gate2")
return Door1, Door2
elseif doorType == "DepsSlide" then
local Door1 = script.Parent:FindFirstChild("Gate1")
local Door2 = script.Parent:FindFirstChild("Gate2")
return Door1, Door2
end
end
function isNil(object)
if object ~= nil then
return false
else
return true
end
end
function TweenDoor(doorType, targetedDoor, tweenInfo, targetedDoor2)
print("Worked!")
if doorType == "Blast" then
local blastTween = TweenService:Create(targetedDoor, tweenInfo, {Position = targetedDoor.Position + Vector3.new(0, targetedDoor.Size.Y, 0)})
blastTween:Play()
end
end
function onTouched(hit, doorType, Door, Door2)
local hum = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid")
if hum then
local character = hum.Parent
if character then
local player = Players:GetPlayerFromCharacter(character)
print(player)
if groupId and groupId2 ~= nil then
local isIn, IsIn2, groupRankRes, groupRankRes2 = checkGroupRank(player, groupId, groupId2)
if isIn then
if groupRankRes and groupRankRes2 then
if groupRankRes >= groupRank and groupRankRes2 >= groupRank2 then
local isNil = isNil(Door2)
if isNil == false then
TweenDoor(doorType, Door, nil, Door2)
else
TweenDoor(doorType, Door, nil)
end
end
end
end
elseif groupId ~= nil then
local isIn, groupRankRes = checkGroupRank(player, groupId)
if isIn then
if groupRankRes ~= nil and groupRankRes >= groupRank then
local isNil = isNil(Door2)
if isNil == false then
TweenDoor(doorType, Door, nil, Door2)
else
TweenDoor(doorType,Door, nil)
end
end
end
elseif groupId2 ~= nil then
local isIn, groupRankRes = checkGroupRank(player, groupId2)
if isIn then
if groupRankRes ~= nil and groupRankRes >= groupRank2 then
local isNil = isNil(Door2)
if isNil == false then
TweenDoor(doorType, Door, nil, Door2)
else
TweenDoor(doorType, Door, nil)
end
end
end
end
end
end
end
-- Actual functionality --
local debounce = false
TouchPart.Touched:Connect(function(hit)
local doorType = searchForInName(script.Parent)
local Door, Door2 = getDoor(doorType)
if Door and Door2 ~= nil then
if debounce == false then
debounce = true
onTouched(hit, doorType, Door, Door2)
wait(2)
debounce = false
end
else
if debounce == false then
debounce = true
onTouched(hit, doorType, Door)
wait(2)
debounce = false
end
end
end)