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

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

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)

2 comments

1

One problem is there's a typo. It says serivce instead of service.

0

that's why It didn't work, thank you.

1 answer

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)

6 comments

0

Still doesn't work.

0

Change line 1 to game.Players.LocalPlayer

0

Nope

0

Works for me, make sure your spelling and caps are right, because it is caps sensitive.

0

My LocalScript is in game.StarterPlayer.StarterPlayerScripts too

0

Found out I spelled Get:Service wrong

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