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

Someone help me with this script?Any Ideas? Chat commands does not work as intended.[UNANSWERED]

Asked by
RoJiyn 12
7 years ago
Edited 7 years ago

Here is the script:

if string.sub(message,1,7) == "health/" then
local number = nil
for i = 8,math.huge do
    if message:sub(i,i) == "/" then
        number = i
        break
    end
    end
    local plr = FindPlayer(message:sub(8,number-1))
    local amt = message:sub(number+1)
    print(plr.Name.."/"..amt)
    end
    end

I tried this

--I chatted this:
"health/pl/8"
--it print this
>Player1/8
--then i tried this
"health//999"
---it print this
>Player1/999
--How do you make it so that when you say this: "health/pla/999"
>Player1/999
---and if you say this: health/NoPlayerThatExist/999
--it will print nothing and not Player1/999

Thanks!!!

1 answer

Log in to vote
-1
Answered by 7 years ago
if message:sub(1,7) == "health/" then
    local number = nil
    for i = 1, math.huge do
            if message:sub(i,i) == "/" then
                number = i
                break
            end
        end
        local plr = FindPlayer(message:sub(8,number-1))
        local amt = message:sub(number+1)
        print(plr.Name.."/"..amt)
end

0
Tried this...still not working... RoJiyn 12 — 7y
0
Tbh your code does like quite messy. I think the error starts at line 3. UltimateRaheem 75 — 7y
Ad

Answer this question