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

Player.Chatted function not working?

Script :

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if msg == "Respawn" then
			plr.Character.Humanoid:TakeDamage(100)
		end
	end)
end)

1 answer

✓ Accepted answer

There's a bug where the roblox chat adds a space at the end of your message.

Try this code until that bug is patched

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        if string.sub(msg, 1, #msg - 1) == "Respawn" then
            plr:LoadCharacter()
        end
    end)
end)

Also, player:LoadCharacter() would be the way to proceed on respawning

1 comment

0

ty

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