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

I do not understand what the problem is, is it a glitch, or is there something missing?

I just got help on the following script, and it works fine.... Well there is one problem. Okay, so lets say I'm on the "Blue Team." I will get killed and that message will pop up. Lets say I switch to the "Red Team." The same will happen when I touch that wall. And now if I change to the "Taxi Driver" team I will go through fine. Yay, all works, but, if I change teams after becoming a taxi driver, I can still go through the wall unharmed and there is no GUI. Here is my script, maybe you can help me figure it out so that even after I become a taxi driver and change teams I cannot enter the wall/door.

local Door = script.Parent 

debounce = false

local modelname="Taxi Driver"

function onTouched(hit) 
        print("Door Hit") 
        local human = hit.Parent:FindFirstChild("Humanoid") 
        

        if (human ~= nil ) and (debounce == false) then
if game.Players:GetPlayerFromCharacter(hit.Parent).TeamColor==game.Teams:FindFirstChild(modelname).TeamColor then
            debounce = true
                        Door.Transparency = 1
                        wait(1) 
                        Door.CanCollide = false 
                        Door.Transparency = 1 
                else
                        human.Health = 0 
						local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
						local gui = Instance.new("ScreenGui", plr.PlayerGui)
						local message = Instance.new("TextLabel", gui)
						message.Size = UDim2.new(1, 0, 1, 0)
						message.BackgroundTransparency = 0.5
                        message.Text = "Player was not a Taxi Driver" 
                        wait(5) 
                        message:Remove()
                end
        end 
end 



Door.Touched:connect(onTouched)


debounce = false

Ps. Thanks to the two guys who helped last time!

1 comment

0

You never set Door.CanCollide to true after disabing it.

1 answer

Golden did find an error, but that still won't harm them, you forgot to reset debounce.

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