Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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!

0
You never set Door.CanCollide to true after disabing it. GoldenPhysics 474 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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

Ad

Answer this question