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

Simple Question About String Splitting, My script wont work! Help?

Asked by 4 years ago

I'm making a script where when you say "Show" and the player's name. It's prints the second value in that string. For example, if I said "show thebeans202" The output should print the beans202. Although, It's NOT printing.. nor is it outputting errors. Any help greatly appreciated.

Here's my script.

local Player = game:GetSerivce('Players').LocalPlayer
local debounce = false


Player.Chatted:Connect(function(message)
    message = message:lower()
    if message:find('show') then
        local tabl3 = message:split(" ")
        print(tabl3[2])
    end

end)

1
One problem is there's a typo. It says serivce instead of service. hoyhyo 2 — 4y
0
that's why It didn't work, thank you. JayShepherdMD 147 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

What a coincidence, I needed to do something like this just now. Here's the script that I used, this should work. The value newv is the second part of the command or tabl3[2]

If this doesn't work, I would consider changing this to a Script, not a local script and just use PlayerAdded to get the LocalPlayer who chatted

local Player = game.Players.LocalPlayer
local debounce = false


Player.Chatted:Connect(function(message)
    if message:find('show') then
    local tabl3 = message:split(" ")
        local newv
        if tabl3[1] == 'show' then
            print(tabl3[2])
        newv = tabl3[2]
    end
    end
end)
0
Still doesn't work. JayShepherdMD 147 — 4y
0
Change line 1 to game.Players.LocalPlayer nogoaway6 20 — 4y
0
Nope JayShepherdMD 147 — 4y
0
Works for me, make sure your spelling and caps are right, because it is caps sensitive. nogoaway6 20 — 4y
View all comments (2 more)
0
My LocalScript is in game.StarterPlayer.StarterPlayerScripts too nogoaway6 20 — 4y
0
Found out I spelled Get:Service wrong JayShepherdMD 147 — 4y
Ad

Answer this question