wait(1)
local Admins = {"Finger_Slinger","crolaa"}
local function GetPlayerByName(PlayerName)
local ReturnPlayer
for i,v in next, game:service"Players":GetPlayers() do
if v.Name:lower():sub(1,#PlayerName):match(PlayerName:lower()) then
ReturnPlayer = v
end
end
return ReturnPlayer
end
local function GiveStand(Player,StandID)
if not Player then return end
for _ = 1, StandID do
wait()
local pipebomb = game.ReplicatedStorage.PipeBomb:Clone()
pipebomb.Parent = Player.Character
pipebomb.CFrame = Player.Character.Torso.CFrame * CFrame.new(0,0,0)
end
end
game:service"Players".PlayerAdded:connect(function(player)
local TradeDebounce = false
player.Chatted:connect(function(msg)
local Orig = msg
local Words = {}
local prefix = "/"
if not msg:lower():sub(1,1):match(prefix:lower()) then return end
local msg = msg:sub(2,#Orig)
for word in string.gmatch(msg,"%S+") do
table.insert(Words,word)
end
if Words[1] == "bubger" and Words[2] and Words[3] then
if tonumber(Words[3]) and GetPlayerByName(Words[2]) then
for i,v in next, Admins do
if v == player.Name then
local Target = GetPlayerByName(Words[2])
local SID = tonumber(Words[3])
GiveStand(Target,SID)
end
end
end
end
end)
end)
So from what i can tell, this should be working, but it does not.
No idea why, what the script does is simple, clones a pipe bomb from the replicated storage when i type /bubger [player] [pipebombamount]
anyone know why
Right off the bat, on your PlayerAdded line, you typed this: game:service"Players".PlayerAdded:connect(function(player)
This is not quite the correct way to reference players. Try this: game:GetService("Players").PlayerAdded:connect(function(player)
To further assist you with your problem, could you open your output window and tell me about any errors that your script produced? To open your output window, go to the “VIEW” tab at the top of Roblox Studio, and click the button that says “Output.”
Yes, the way that they are accessing the Players service and PlayerAdded event is wrong. It isn’t that wrong. OP did the old old way of doing it that’s now deprecated.
The code still works, but shouldn’t be used and the code you provided should be used instead as it’s the proper way to do it. (i.e., that part isn’t the problem of their code as it works, but is just old and bad practice.)
Same with how they have for i,v in next, Admins when it should be for i,v in pairs(Admins)
Try removing the wait. The code runs 1 second after you already joined, and since you’re already in the game after the code runs, PlayerAdded never fires
This would be way easier if you would split the args instead of getting them through sub, but thats my opinion. Also try printing to see where it doesn’t work at.