Hello! I wanted to know how do I make custom commands, so for example I want it to give me coins so something like “;give user 1000 Coins”. I want this only for me and my friend not a group rank or id so is there a way to set that up?
I’d recommend you to check some of the admin systems currently available on the market before anything, but if you want something custom then you’d need to make a script that can check what the user says and split it into args by spaces using local args = string.split(chat, " ");
.
When done, check if args[1] is the prefix and the give command, search for args[2] in the player list using FIndFIrstChild or a similar function, args[3] would be the value (i think, considering that’s how you want it to work by the post) and args[4] to be the leaderstat / the value that stores the coins.
then just do value = value + args[3]
.
local prefix = “:”
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
msg = string.lower()
if msg == prefix…‘give’…plr.Name…–convert it to number here…‘coins’ then
plr.leaderstats.coins.Value = plr.leaderstats.coins.Value + --Continue
end
end)
end)
Ill try it! Thank you so much!
Hmmmm ok, I will try looking at some
so i kinda pressed enter accidentally lmao
local function FindPlayer(name)
for _, player in next, game.Players:GetChildren() do -- dont ask why i use next lol
if string.sub(player.Name, 1, #name):lower() == name:lower() then
return player
end
return nil
end
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local splt = msg:split(' ')
if splt[1] ~= ';give' then return end
if #splt == 4 then
local player = splt[2]
if FindPlayer(player) then
local player = FindPlayer(player)
if player:IsA('Player') ~= true then return end
for i, v in pairs(player.leaderstats:GetChildren()) end
if v:lower() == splt[4]:lower() then
v.Value += tonumber(splt[3]) or 0
end
end
end
end
end)
end)