Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Command to change a number value?

Asked by
moo1210 587 Moderation Voter
7 years ago
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

Log in to vote
0
Answered by
tber8 37
7 years ago

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
0
...And if the player chats :outscore 6 then what? ScriptGuider 5640 — 7y
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. ScriptGuider 5640 — 7y
0
I'm not advanced enough a scripter to know how to capture a number in chat and transfer it to a number value. tber8 37 — 7y
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. moo1210 587 — 7y
View all comments (4 more)
0
Also can you just do = 5 if you don't want to add 5 just make it 5? moo1210 587 — 7y
0
Please don't do that. That is a horribly ugly solution. I'll work on an answer. ScriptGuider 5640 — 7y
0
yay :D tber8 37 — 7y
0
Okay @ScriptGuider do that. Thats what am looking for. moo1210 587 — 7y
Ad

Answer this question