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

Team Flag Script Not Working. Always printing the error code i made?

Asked by 4 years ago

Hello, i am having a problem with this script, it is a script to pick up a flag and lower a value, but that is not a problem, it is a function to stop the same team from picking up their own flag. It always prints invalid (that i have put to check), even if i am in the opposite team.

Here's the code:

function checkplayer(hit)
    local player = players:GetPlayerFromCharacter(hit.Parent)
    local playername = hit.Parent.Name
    local human = hit.Parent:FindFirstChild("Humanoid")
    if  human then
    if not players[playername].TeamColor == BrickColor.new("Bright blue") then
    ontouchorremove()
    print("valid")
    else
        print("invalid")
    end 
    end
    end

    script.Parent.Touched:Connect(checkplayer)
0
I think you could swap BrickColor.new("Bright blue") for just == "Bright blue" and make sure everything was wrote right kevinsoaresv 47 — 4y
0
i already did that goodnoodle13 39 — 4y
0
...And? kevinsoaresv 47 — 4y
0
nope, still the same goodnoodle13 39 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

I have recently updated the script, no worry's. I changed the 6th line to a if then statement instead than a if not then statement. Also, i had to add a argument for calling my other function.

function checkplayer(part)
    local playername = part.Parent.Name
    local human = part.Parent:FindFirstChild("Humanoid")

    if  players[playername].TeamColor == BrickColor.new("Bright red") then

    ontouchorremove(part)
    print("valid")
    else
        print("invalid")
    end 
    end

    script.Parent.Touched:Connect(checkplayer)
Ad

Answer this question