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

How to access a Table through a Chatted command? [Solved]

Asked by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

Well, the title may be simpler than it is. I've worked on this script that should change a Model's appearance on command. When I do, the script runs full through with no errors, but the Model's appearance doesn't change. Any tips?

local asset = "http://www.roblox.com/asset/?id="
local Team = "Really blue"
local Prefix = "!" -- Prefix: "!char 1"
local ChangeChar = game.Workspace["Memorize Me"]

Characters = {
    {145379994,114305180,16630147}; -- Following order: Shirt ID (Make sure to -1), Pants ID (Make Sure to Minus one), Hat ID (You don't need to minus)
}


game.Players.PlayerAdded:connect(function(p)
    p.Chatted:connect(function(msg)
        print('1')
        if p.TeamColor == BrickColor.new(Team) then
            print('2')
            local cmd = string.sub(msg,1,5)
            local number = string.sub(msg,7)
            print('3')
            if cmd == Prefix.."char" then
                print('4')
                if (tonumber(string.sub(msg,7)) <= #Characters) then
                    print('5')
                    for i,v in pairs(ChangeChar:GetChildren()) do
                        if v:IsA("Hat") then
                            v:Destroy()
                        end
                    end 
                    print ('6')
                    ChangeChar.Shirt.ShirtTemplate = asset..Characters[(tonumber(string.sub(msg,7)))][1] -- Doesn't change
                    print('7')
                    ChangeChar.Pants.PantsTemplate = asset..Characters[tonumber(string.sub(msg,7))][2]
                    print('8')
                    game:GetService("InsertService"):LoadAsset(Characters[tonumber(string.sub(msg,7))][3]):GetChildren()[1].Parent = ChangeChar
                    print('9')
                end
            end
        end
    end)
end)
0
I still don't see why someone feels the urge to down my question, just because it may seem complex. Shawnyg 4330 — 9y
0
Voted your question to neutral. I'm not sure if this relevant, but on line 29 you put an extra parenthesis, one before tonumber and one before the bracket. aquathorn321 858 — 9y
0
@Aqua, Thanks, but that still didn't change anything. Thank you for trying. Shawnyg 4330 — 9y

Answer this question