I was making a button script that activates and deactivates certain parts, and when you die, all the parts deactivate.
But for another section, I wanted to make different sections available whether you went with the blue button or red button.
So I made a green thing that makes it so when you die, it keeps the parts that were activated from deactivating.
But for some reason, if the redbutton was activated and I die, and the green wall was activated, I can still roll.
local collectionservice = game:GetService('CollectionService')
local part = collectionservice:GetTagged('ButtonRed')
local part2 = collectionservice:GetTagged('ButtonBlue')
local part3 = collectionservice:GetTagged('GreenActivate')
local player = game.Players.LocalPlayer
local bass = workspace.buttonsound
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild('Humanoid')
local starterchar = char:FindFirstChild('RollAbility')
local isRedActivated = false
local greenactivate = false
local redactivated = collectionservice:GetTagged('RedActivate')
local blueactivated = collectionservice:GetTagged('BlueActivate')
local isBlueActivated = false
local ts = game:GetService('TweenService')
local ti = TweenInfo.new(1,Enum.EasingStyle.Exponential,Enum.EasingDirection.InOut,0,true)
local ti2 = TweenInfo.new(1,Enum.EasingStyle.Exponential,Enum.EasingDirection.InOut,0,false)
local Players = game:GetService('Players')
for _, tagged in pairs(part) do
tagged.Touched:Connect(function(TheBigPart)
if isRedActivated == true then
return
end
local humanoid = TheBigPart.Parent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
isRedActivated = true
isBlueActivated = false
bass:Play()
local partTween = ts:Create(tagged,ti,{CFrame = tagged.CFrame * CFrame.new(0,-0.9,0)})
partTween:Play()
for _, tagged2 in pairs(redactivated) do
local transparency = ts:Create(tagged2,ti2,{Transparency = 0})
transparency:Play()
tagged2.CanCollide = true
starterchar.Disabled = true
end
for _, tagged3 in pairs(blueactivated) do
local transparency = ts:Create(tagged3,ti2,{Transparency = 0.7})
transparency:Play()
tagged3.CanCollide = false
end
end
end)
end
for _, tagged3 in pairs(part2) do
tagged3.Touched:Connect(function(TheBigPart)
if isBlueActivated == true then
return
end
local humanoid = TheBigPart.Parent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
isBlueActivated = true
isRedActivated = false
bass:Play()
local partTween = ts:Create(tagged3,ti,{CFrame = tagged3.CFrame * CFrame.new(0,-0.9,0)})
partTween:Play()
for _, tagged2 in pairs(redactivated) do
local transparency = ts:Create(tagged2,ti2,{Transparency = 0.7})
transparency:Play()
tagged2.CanCollide = false
end
for _, tagged2 in pairs(blueactivated) do
local transparency = ts:Create(tagged2,ti2,{Transparency = 0})
transparency:Play()
tagged2.CanCollide = true
starterchar.Disabled = false
end
end
end)
end
for _, tagged4 in pairs(part3) do
tagged4.Touched:Connect(function(TheBigPart)
if greenactivate == true then
return
end
local humanoid = TheBigPart.Parent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
greenactivate = true
end
end)
end
humanoid.Died:Connect(function()
starterchar.Disabled = false
if greenactivate == true then
print("HI")
if isRedActivated == true then
print('HELLO')
if starterchar == false then
print('WHAT')
starterchar.Disabled = true
end
end
return
end
for _, tagged in pairs(redactivated) do
local transparency = ts:Create(tagged,ti2,{Transparency = 0.7})
transparency:Play()
tagged.CanCollide = false
end
for _, tagged2 in pairs(blueactivated) do
local transparency2 = ts:Create(tagged2,ti2,{Transparency = 0.7})
transparency2:Play()
tagged2.CanCollide = false
end
end)