"Unable to cast value to object"

game.Players.PlayerAdded:Connect(function(player)
	player.chatted:Connect(function(NewMsg)
		print(NewMsg)
		for _, V in pairs(game.Players:GetChildren()) do
			if V.SettingsFolder.AllChatVisible.Value == true then
				Event:FireClient(V.Name, player.DisplayName.."(Chat)", NewMsg)
			end
		end
	end)
end)

Not sure what the issue is here, at like 20 in my script (the line that fires an event) is giving me an error saying “Unable to cast value to object”

Thanks for any help!

Try this, you were using “player.chatted” It’s supposed to be “player.Chatted”

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(NewMsg)
        print(NewMsg)
        for _, V in pairs(game.Players:GetPlayers()) do
            if V.SettingsFolder.AllChatVisible.Value == true then
                Event:FireClient(V.Name, player.DisplayName.."(Chat)", NewMsg)
            end
        end
    end)
end)

thats not the issue here, that wont change anything. the issue is coming from the event firing

Check that the parameters passed to the FireClient method are correct and match the expected parameters on the client side.

game.Players.PlayerAdded:Connect(function(player)
	player.chatted:Connect(function(NewMsg)
		print(NewMsg)
		for _, V in pairs(game.Players:GetChildren()) do
			if V.SettingsFolder.AllChatVisible.Value == true then
				Event:FireClient(player, V.Name, player.DisplayName.."(Chat)", NewMsg)
			end
		end
	end)
end)

you have to pass a player object first, not just a player name

1 Like

ohhhhh ok thank you
char limit

2 Likes

that worked, i always get thoses mixed up for remotes
Thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.