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

I just need to prove the concept working but it's not, so how do i fix it?

Local Script:

wait()
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Lce = ReplicatedStorage:WaitForChild("LCE")
jun = Players.LocalPlayer
 
jun.Chatted:Connect(function(Msg)
local msg = Msg:lower()
if string.sub(msg, 1, 7) == "LG" then
wait(0.1)
Lce:FireServer()
end
end)

Server Script:

wait()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Lce = ReplicatedStorage:WaitForChild("LCE")
 
Lce.OnServerEvent:Connect(function(player)
	print(player.Name , "Works")
	
end)

7 comments

0

if string.sub(msg, 1 ,2) == 'LG' then *

0

still nothing

0

Remove Msg:lower() because "LG" is capital. Or just do Msg:upper().

0

even with the lg not being capital it's still the same

0

why r u using sub? u should use string.find

0

Make else statements to check if the if statement's conditional is actually true(In your LocalScript, the "LG" part of the if statement on line 8 should be lowercase because you use the lower function and that makes all the string's characters lowercase. In addition, you are checking for 2 letters when you are checking for 7).

0

if Msg:sub(1, 2):lower() == "lg" then ... end

1 answer

✓ Accepted answer

###This is because you used the string.sub function incorrectly. You checked if from letter 1 to 7, the string equaled "LG", when you should just have checked from 1 to 2. You also checked if the string in lowercase equaled uppercase, which obviously it won't. You also didn't need any remotes, you can handle the Chatted event on the server.

-- Server script
wait()
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(Msg)
        if Msg:sub(1, 2):upper() == "LG" then -- check from substring 1-2
            wait(0.1)
        end
    end)
end)




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