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

I have a problem with TeamColor?

Asked by 8 years ago

I am making a script for a terminal/flag that your team captures. This is a local script in Starterpack. Here's the script:

plr = game.Players.LocalPlayer
char = plr.Character
tc = plr.TeamColor

while true do
    if game.Workspace.Terminal then -- If the gamemode is Terminal

        terminal = game.Workspace.Terminal  
        wait(1)
        local magnitude = (char.Torso.Position - terminal.Flagpole.Position).magnitude

if magnitude <= 35 then
    print("Player near terminal")

        if tc == BrickColor.new(21) then

            print(plr.TeamColor)
            terminal.captureprogress.Value = terminal.captureprogress.Value + 1
            print(terminal.captureprogress.Value)

        else
            print(plr.TeamColor)
            terminal.captureprogress.Value = terminal.captureprogress.Value - 1
            print(terminal.captureprogress.Value)
end
end
end
end

The problem is this block:

if tc == BrickColor.new(21) then

            print(plr.TeamColor)
            terminal.captureprogress.Value = terminal.captureprogress.Value + 1
            print(terminal.captureprogress.Value)

        else
            print(plr.TeamColor)
            terminal.captureprogress.Value = terminal.captureprogress.Value - 1
            print(terminal.captureprogress.Value)

The capture progress is an intvalue and the value should be getting bigger when a red team is near the terminal and if the other teams go near the terminal the intvalue's value gets smaller. But in game it gets bigger even if i'm on the other team... The script does recognize I'm on the other team because it prints my TeamColor but the value doesn't decrease.

I changed the BrickColor.new(21) to aBrickColor.new(2) (which isn't a color, and the number was subtracting.)

Any ideas how I could approach this issue?

1
You are supposed to use a Server Script for this stuff >.> laughablehaha 494 — 8y
0
I changed it to a server script and it still had the same problem. Dx zipper01 62 — 8y
1
A ServerScript inside Workspace, preferrably the terminal >.> Discern 1007 — 8y

Answer this question