if args[1] == prefix..'spawn' then
if args[2] == nil then
return
end
for i,v in pairs(game.ReplicatedStorage.food:GetChildren()) do
if args[2] == v.Name then
print('GOSH')
local cloned = v:Clone()
cloned.Name = 'test'
cloned.Position = plr.Character.HumanoidRootPart.Position + Vector3.new(0,0,3)
cloned.Parent = workspace
cloned.Anchored = false
return
end
end
end
from this snippet i think that if the args[2] = to the name of the instance, it will print gosh, to its thing
then i return for it to not spawn more then 1 part. gosh is printed more then once and it spawns parts more then once? wth btw this is a serverscript in serverscriptservice
i am not entirely sure what u mean by that, but here is my full script
local prefix = "/"
local admins = {
1870270151,
2750291481,
5131398974,
2879596566,
4110539419,
2017684638,
5627938864
}
game.Players.PlayerAdded:Connect(function(plr)
local Admin = false
for _, userId in admins do
print(userId .. " " .. plr.UserId)
if userId == plr.UserId then
Admin = true
end
if Admin == true then
plr.Chatted:Connect(function(msg)
local loweredString = string.lower(msg)
local args = string.split(loweredString," ")
if args[1] == prefix..'spawn' then
if args[2] == nil then
return
end
for i,v in pairs(game.ReplicatedStorage.food:GetChildren()) do
if args[2] == v.Name then
print(v.Name)
print('GOSH')
local cloned = v:Clone()
cloned.Name = v.Name
cloned.Position = plr.Character.HumanoidRootPart.Position + Vector3.new(0,0,3)
cloned.Parent = workspace
cloned.Anchored = false
break
end
end
end
end)
end
end
end)
i can assure you my id is in that list and this time NOTHING spawns in
new code: u told me to put this way
local prefix = "/"
local admins = {
1870270151,
2750291481,
5131398974,
2879596566,
4110539419,
2017684638,
5627938864
}
game.Players.PlayerAdded:Connect(function(plr)
local Admin = false
Admin = table.find(admins,plr.UserId)
if Admin == true then
plr.Chatted:Connect(function(msg)
local loweredString = string.lower(msg)
local args = string.split(loweredString," ")
if args[1] == prefix.."luck" then
for _,player in pairs(game:GetService("Players"):GetPlayers()) do
if string.sub(string.lower(player.Name), 1, string.len(args[2])) == string.lower(args[2]) then
game.ReplicatedStorage.remotes.LuckBoost:FireClient(plr, player , args[3])
end
end
end
if args[1] == prefix..'spawn' then
if args[2] == nil then
return
end
for i,v in pairs(game.ReplicatedStorage.food:GetChildren()) do
if args[2] == v.Name then
print(v.Name)
print('GOSH')
local cloned = v:Clone()
cloned.Name = v.Name
cloned.Position = plr.Character.HumanoidRootPart.Position + Vector3.new(0,0,3)
cloned.Parent = workspace
cloned.Anchored = false
break
end
end
end
end)
end
end
end)
While changing my code to your recommendaton, i also unknowingly added an “end”, messing the whole code up and since i have alot of prints (in other scripts) i dint realize it was printing an error. i removed the
“end” and your code is working. thank you