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

I need help with tables?

Asked by 9 years ago

so i made a script on tables and this is what i came up ( i got it from freemodels then modified it a bit so im actually trying to learn how to script plss dont sue me from copying it @_@)

ppl = 1
        repeat
            ppl = ppl + 1
            p = game.Players:GetChildren()
            team2 = {}
            team3 = {}
            for num, obj in pairs(p) do
                if obj then
                    if obj.PlayerGui.Play.Alive.Value then
                        if obj.TeamColor == BrickColor.new("Bright red") then
                            table.insert (team2,obj)
                        elseif obj.TeamColor == BrickColor.new("Bright blue") then
                            table.insert (team3,obj)
                        end
                    end
                end

so it is possible to make a script where in if player in team3 touched a part named blah blah blah(only team3 can touch it) then blah blah happens? if yes so how? ow and where can i learn scripting?

0
What happens if it isn't a person from Team3 fahmisack123 385 — 9y
0
nothing happens. Arnel050039 20 — 9y

1 answer

Log in to vote
1
Answered by
DataStore 530 Moderation Voter
9 years ago

To do what you wanted to do you wouldn't need to use a table at all. To achieve what you've asked you simply need to use the Touched event and an if statement. An example is shown below.

script.Parent.Touched:connect(function(Part) --// Anonymous function 
    local Player = game.Players:GetPlayerFromCharacter(Part.Parent) --// Getting the player object associated with the touched part's parent - If there isn't one this variable will be nil later on when used.
    if Player and Player.TeamColor == BrickColor.new("Bright blue") then --// Checks if the player variable isn't nil, and checks whether their TeamColor is the Bright blue brickcolor. 
        print("The player is real, and their team is blue.") 
    end --// Ending the if statement
end) --// Anonymous function end

To learn more about scripting, take a look at the ROBLOX Wiki, or alternatively look around online or on the ROBLOX forums.

0
really helped thanks :D.. ow and i forgot to mention that the script is in workspace ;-;..btw is it possible to have a script like this in workspace not in a part? Arnel050039 20 — 9y
0
Yes. You just need to change the 'script.Parent' to point to the part in Workspace. For example, Workspace.ThePart.Touched DataStore 530 — 9y
Ad

Answer this question