I’ve made a command system for my game and so when I try to set a value to something with a space it doesn’t seem to work and I can’t figure out why. The command is set out as ‘set,plr,valuetochange,value’, and here’s the commands code, if you can help please do:
if string.match(msg, "set,[%w_]+,[%w]+,[%P]+") then
local playername = string.gsub(msg,"set,","")
playername = string.match(playername, "^[%w_]+")
for i,v in pairs(game.Players:GetPlayers()) do
if v.Name:lower():sub(1,#playername) == playername:lower() then
local player = v
if not table.find(blacklist, player.Name) then
local valuename = string.gsub(msg,",[%w]+$","")
valuename = string.match(valuename,"[%w]+$")
for i,b in pairs(player.ValueFolder:GetChildren()) do
if b.Name:lower():sub(1,#valuename) == valuename:lower() then
local value = b
local amountname = string.match(msg,"[%P]+$")
print(value)
print(amountname)
if value.Name == "Race" and not game.ServerStorage.Races:FindFirstChild(amountname) then
amountname = "None"
end
if value.Name == "Weapon" and not game.ServerStorage.Items.Weapons:FindFirstChild(amountname) then
amountname = "Sword"
end
if amountname == "TheDeep" then
amountname = "The Deep"
end
if commandexe == false then
if table.find(adminvalues, value.Name) or table.find(adminamounts, amountname) then
if table.find(adminperms, plr.Name) then
value.Value = amountname
commandexe = true
end
else
value.Value = amountname
commandexe = true
end
spawn(function()
local soundc = sound:Clone()
soundc.Parent = player.Character
soundc:Play()
wait(3)
soundc:Destroy()
end)
wait()
commandexe = false
end
end
end
end
end
end
This is only the main part of the command script, if you need more then I can share if needed.