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

Why won't this OnChatted script work?

Asked by 10 years ago

I am trying and trying, it just won't work. I'm not sure what is wrong. I have the lighting objects correct , it's the script that's failing

Why won't it work?

admin = { "FergotCheese","StargateOne" }
game.Players.PlayerAdded:connect(function(nP)
for _,v in pairs(admin) do
if nP.Name == v then
nP.Chatted:connect(function(msg)
if msg == "Run/Aim" then
x = game.Lighting.Aim:Clone()
M = Instance.new("Hint")
M.Parent = game.Workspace
M.Text = "Ran Aim"
wait(0.1)
x.Parent = game.Workspace
wait(3)
M:Remove()
end
end)
end
end
end)

if msg == "End/Aim" then
M = Instance.new("Hint")
M.Parent = game.Workspace
M.Text = "Ended Aim"
game.Workspace.Aim:Remove()
wait (1)
M:Remove()
end
end)
end
end
end)

1 answer

Log in to vote
0
Answered by 10 years ago
admin = { "FergotCheese","StargateOne" }

function isAdmin(plrname)
    for _,v in pairs(admin) do
        if plrname == v then
            return true
        end
    end
    return true
end

game.Players.PlayerAdded:connect(function(nP)
    if isAdmin(nP.Name) then
        nP.Chatted:connect(function(msg)
            if msg == "Run/Aim" then
                x = game.Lighting.Aim:Clone()
                M = Instance.new("Hint")
                M.Parent = game.Workspace
                M.Text = "Ran Aim"
                wait(0.1)
                x.Parent = game.Workspace
                Game:GetService("Debris"):AddItem(M, 3) -- add M to debris, and remove after 3 seconds
            end

            if msg == "End/Aim" then
                M = Instance.new("Hint")
                M.Parent = game.Workspace
                M.Text = "Ended Aim"
                game.Workspace.Aim:Remove()
                Game:GetService("Debris"):AddItem(M, 1) -- add M to debris, and remove after 1 second
            end
        end)
    end
end)
Ad

Answer this question