Attempt to call nil value

Help me resolve the problem.

The script isn’t working and I don’t know why the script isn’t working.

We tried serval times to test it and nothing is working.

local Text = workspace.MicrophoneBoard.SurfaceGui.TextLabel.Text
local GetPlayer = workspace.GetPlayer

game.Players.PlayerAdded:Connect(function(plrs)
    GetPlayer.Touched:Connect(function()
        plrs.Chatted:Connect(function(msg)
            function Touched(hit)
                local human = hit.GetPlayer:findFirstChild("Humanoid")
                if human.Touched.GetPlayer then
                    if msg then
                        Text = msg
                    end
                end
            end
        end)
    end)
end)

GetPlayer.Touched:connect(Touched)

Output: image

2 Likes

GetPlayer.Touched is connected when the game first starts, whereas the function isn’t defined until someone talks.

4 Likes

please tell us what this script should do

local Text = workspace.MicrophoneBoard.SurfaceGui.TextLabel.Text
local GetPlayer = workspace.GetPlayer

game.Players.PlayerAdded:Connect(function(plrs)
    GetPlayer.Touched:Connect(function()
        plrs.Chatted:Connect(function(msg)
            function Touched(hit)
                local human = hit.GetPlayer:findFirstChild("Humanoid")
                if human.Touched.GetPlayer then
                    if msg then
                        Text = msg
                    end
                end
            end
            GetPlayer.Touched:Connect(Touched)
        end)
    end)
end)

This should work

Fixed it, thanks everyone who replied! We changed the whole script to something different.

1 Like