Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Command to change a number value?

local admins = {"moo1210","Player","Player1"}
 
function tableContains(t, value)
    for _, v in pairs(t) do
        if v == value then 
            return true
        end
    end
    return false
end
 
function onChatted(message, player)
    if message == ":outscore" and tableContains(admins, player.Name) then

So am trying to make it so if I did :outscore 5 it would change a number value to 5 it is under ServerStorage and the number value is called Outscore. Please help me, Thanks! If anything is wrong in this script also help me with that. Post the full code for this command.

1 answer

There is nothing clearly incorrect and the command is simple. All that you need to do is get the object with the value and change the value inside it. The command would be as follows:

game.ServerStorage.Outscore.Value = 5

Then to further add to this you could instead add to gain value:

game.ServerStorage.Outscore.Value = game.ServerStorage.Outscore.Value + 5

If you are looking for adding or making the value the number said, it gets more complex. If you want it to be the number that you chatted, that might be pretty hard. With my version, the command would add 5. This is what I would do:

local admins = {"moo1210","Player","Player1"}

function tableContains(t, value)
    for _, v in pairs(t) do
        if v == value then 
            return true
        end
    end
    return false
end

function onChatted(message, player)
    if message == ":outscore" and tableContains(admins, player.Name) then
    game.ServerStorage.Outscore.Value = game.ServerStorage.Outscore.Value + 5

8 comments

0

...And if the player chats :outscore 6 then what?

0

You should be able to capture the argument(s) of the command using a subordinate string. That's what he's looking for, at least.

0

I'm not advanced enough a scripter to know how to capture a number in chat and transfer it to a number value.

0

What if you wanted to do :outscore 5 for that or :outscore 6 for that but that just gives me an idea ill make a 11 scripts one for 1 a other for 2 and up to 11.

0

Also can you just do = 5 if you don't want to add 5 just make it 5?

0

Please don't do that. That is a horribly ugly solution. I'll work on an answer.

0

yay :D

0

Okay @ScriptGuider do that. Thats what am looking for.

This discussion is preserved as it was. New answers, comments, and votes are closed.