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

Roblox wont let my script work it only works if i go disable it then enable it ?

Asked by 6 years ago
Edited 6 years ago

ok so I made this admin script, I think the code is perfect

-- made by vocules

Admins = {"Vocules","Player1","Player2"} -- put the admins here

Prefix = "-" -- Change to your prefix  you want
for i,v in pairs (game.Players:GetPlayers()) do
    v.Chatted:connect(function(msg)
        if msg:lower() == Prefix .. "help" then
            print(Admins[math.random(0,3)])
        end
    end)
end

then I ran into some lame problem I try to press play and then i say -help and then it doesnt print it, but if I go to properties when im playing it disabled and then enable the script everytime i say help it works.. but that is just a pain plus there is no properties in the roblox game.

the script is global and in workspace.

0
in other words the script only runs once and that is before the player even loaded Ind1v1duals 43 — 6y
0
You should be the PlayerAdded event. User#5423 17 — 6y

1 answer

Log in to vote
0
Answered by
UgOsMiLy 1074 Moderation Voter
6 years ago

Use the PlayerAdded Event.

Admins = {"Vocules","Player1","Player2"} -- put the admins here

Prefix = "-" -- Change to your prefix  you want
game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(msg)
        if msg:lower() == Prefix .. "help" then
            print(Admins[math.random(0,3)])
        end
    end)
end)
Ad

Answer this question