You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Opening a door animation -
What is the issue? Include screenshots / videos if possible!
It works when its above ground but here it doesn’t work, not sure why, and sometimes it does but only once.
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, true, 0.5)
-- Functions --
function TweenDoor (targetedDoor, tweenInfo, targetedDoor2)
local blastTween = TweenService:Create(targetedDoor, tweenInfo, {Position = targetedDoor.Position + Vector3.new(0, targetedDoor.Size.Y, 0)})
blastTween:Play()
end
function tweenText(text, tweenInfo)
local textTween = TweenService:Create(text, tweenInfo, {Position = text.Position + Vector3.new(0, script.Parent.Door.Size.Y, 0)})
textTween:Play()
end
-- Actual functionality --
local debounce = false
TouchPart.Touched:Connect(function(hit)
if debounce == false then
debounce = true
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)
tweenText(Text1, blastDoorTweenInfo)
tweenText(Text2, blastDoorTweenInfo)
wait(2)
debounce = false
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)
tweenText(Text1, blastDoorTweenInfo)
tweenText(Text2, blastDoorTweenInfo)
wait(2)
debounce = false
end
else
TweenDoor(script.Parent:WaitForChild("Door"), blastDoorTweenInfo)
tweenText(Text1, blastDoorTweenInfo)
tweenText(Text2, blastDoorTweenInfo)
wait(2)
debounce = false
end
end
end
end
end)